请问在布局管理器里如何使用其他布局管理器如:使用FlowLayout设置一三行的窗口布局
Container contentPane = f.getContentPane();
FlowLayout lay = new FlowLayout(0,0,1);
contentPane.setLayout(lay); JPanel top = new JPanel();
top.setBackground(Color.WHITE);
top.setPreferredSize(new Dimension(350,60));
contentPane.add(top);
JPanel center = new JPanel();
center.setBackground(Color.lightGray);
center.setPreferredSize(new Dimension(350,130));
contentPane.add(center);
JPanel bottom = new JPanel();
bottom.setBackground(Color.GRAY);
bottom.setPreferredSize(new Dimension(350,70));现在要在中间 center中加其他布局,请问用什么方法加啊
Container contentPane = f.getContentPane();
FlowLayout lay = new FlowLayout(0,0,1);
contentPane.setLayout(lay); JPanel top = new JPanel();
top.setBackground(Color.WHITE);
top.setPreferredSize(new Dimension(350,60));
contentPane.add(top);
JPanel center = new JPanel();
center.setBackground(Color.lightGray);
center.setPreferredSize(new Dimension(350,130));
contentPane.add(center);
JPanel bottom = new JPanel();
bottom.setBackground(Color.GRAY);
bottom.setPreferredSize(new Dimension(350,70));现在要在中间 center中加其他布局,请问用什么方法加啊
首先:JPanel coner1 = new JPanel(new FlowLayout());
coner1.add(add);
coner1.add(exit);
然后把coner1添加到center中,这样就可以了哈!
center.setLayout(new SomeLayout());