能编译不能运行 麻烦大神看下代码
package yxl;
import javax.swing.*;
import java.awt.*;
public class testPanels extends JFrame {
public testPanels(){
//create p1
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(4,3));
//add button to p1
for(int i=1;i<10;i++){
p1.add(new JButton(""+i));
}
p1.add(new JButton(""+0));
p1.add(new JButton("Start"));
p1.add(new JButton("Stop"));
//create p2 to hold textfield an p1
JPanel p2 = new JPanel(new BorderLayout());
p2.add(new JTextField("Time to be display here"),BorderLayout.NORTH);
p2.add(p1);
//add content to frame
add(p2,BorderLayout.EAST);
add(new JButton("Food to be placed here"),BorderLayout.CENTER);
}
public static void mian(String[] args){
testPanels frame= new testPanels();
frame.setTitle("The front View of a Microwave Oven");
frame.setSize(400,250);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
[解决办法]
main写成了mian