2 u012416759 u012416759 于 2014.10.26 23:35 提问

Java中BorderLayout的一些奇怪问题。。。

BorderLayout布局的JPanel为什么不能多次“嵌套”?求高手指点

public class Test extends JFrame{
private BorderLayout borderLayout = new BorderLayout(5,0);
private JPanel p1 = new JPanel();
private JPanel p2 = new JPanel();
public Test() {
    this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    this.p1.setLayout(borderLayout);
    this.p2.setLayout(borderLayout);
    this.p1.add(new JButton("RRRR"),BorderLayout.NORTH);
    this.p1.add(new JButton("qqqq"),BorderLayout.CENTER);
    this.p1.add(new JButton("www"),BorderLayout.SOUTH);
    this.p2.add(p1,BorderLayout.NORTH);
    this.add(p2);
    this.setSize (400,600);
    this.setVisible(true);
}
public static void main(String[] args){
    Test t = new Test();
}

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!