package bottntest;
import java.awt.*;
import javax.swing.*;
public class BoxLayout1 extends JFrame{
private JPanel jp = new JPanel();
private JPanel jpy = new JPanel();
private JPanel jpx = new JPanel();
BoxLayout1(){
jpy.setLayout(new BoxLayout(jpy,BoxLayout.Y_AXIS));
for(int i = 1;i<=5;i++){
jpy.add(new JButton("jpy "+i));
}
jpx.setLayout(new BoxLayout(jpy,BoxLayout.X_AXIS));
for(int j = 1;j <= 5;j++){
jpx.add(new JButton("jpx "+j));
}
jp = (JPanel)getContentPane();
jp.setLayout(new BorderLayout());
jp.add(jpy,BorderLayout.EAST);
jp.add(jpx,BorderLayout.SOUTH);
setBounds(150,150,450,200);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new BoxLayout1();
}
}
为什么会有执行错误说setVisible(true);
有错误.请指点.