新手求指教 怎样才能在布局里面放布局
比如说在中间里面放入一个布局让他成这样第二个那样 希望高手帮我改一下import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class mybiankuan2 extends JFrame {
JButton jb1,jb2,jb3,jb4;
JPanel jb5;
public mybiankuan2(){
anniu();
GridLayout gri=new GridLayout(2,1);
this.setLayout(gri);
JButton jb1=new JButton("北");
JButton jb2=new JButton("南");
this.add(jb1);
this.add(jb2,"Center");
this.setBounds(20, 30, 200, 200);
}
public void anniu(){
JButton jb3=new JButton("西");
JButton jb5=new JButton("中间");
this.add(jb3,"West");
this.add(jb5,"Center");
}
public static void main(String[] args) {
mybiankuan2 my1=new mybiankuan2();
my1.setVisible(true);
}
}
----------------解决方案--------------------------------------------------------
利用Panel
实例化一个Panel a;
可以调用a.add();
然后在布局里添加this.add(a);
----------------解决方案--------------------------------------------------------