我想在同一个框架中使用 2 个面板。但是按钮不起作用?我怎么做?我想在一个面板中放置几个按钮,而另一个面板会做一些其他的事情。
public class TestingPage extends JFrame {
JFrame frame=new JFrame();
JPanel panel01;
JPanel panel02;
JButton bttn1;
/**
* @param args
*/
public TestingPage(){
super("Test");
setBounds(700,700,650,500);
setVisible(true);
setLayout(new BorderLayout());
Container cont=frame.getContentPane();
panel01=new JPanel();
panel02=new JPanel();
cont.add(panel01,BorderLayout.EAST);
cont.add(panel02,BorderLayout.WEST);
//setLayout(new BorderLayout());
bttn1=new JButton("Button");
bttn1.setBounds(77, 75, 100,26);
add(bttn1);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Runnable guiCreator= new Runnable(){
@Override
public void run (){
TestingPage page=new TestingPage();
}
};
javax.swing.SwingUtilities.invokeLater(guiCreator);
}
}