请帮我看看这段代码有什么问题...
为什么什么都不显示啊
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyFrame extends JFrame{
MyFrame(String s){
super(s);
JPanel p1 = new JPanel();
p1.setLayout(new BorderLayout());
p1.add(new JButton("Okay"), BorderLayout.SOUTH);
JPanel p2 = new JPanel();
p2.setLayout(new BorderLayout());
p2.add(new JButton("lala"), BorderLayout.WEST);
setVisible(true);
setSize(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args){
MyFrame f=new MyFrame("123");
}
}
------解决方案--------------------------------------------------------
你只new了panel 并没把他们加到Frame上,以后要细心啊