大致代码如下:
Container container = this.getContentPane();//this值JFrame什么的
container.setLayout( new GridLayout(3,1) );JPanel firstPanel = new JPanel();JPanel secondPanel = new JPanel();
secondPanel.setLayout( new GridLayout(1,5) );JPanel thirdPanel = new JPanel();
thirdPanel.setLayout( new GridLayout(1,3) );container.add( firstPanel );
container.add( secondPanel );
container.add( thirdPanel );
Container container = this.getContentPane();//this值JFrame什么的
container.setLayout( new GridLayout(3,1) );JPanel firstPanel = new JPanel();JPanel secondPanel = new JPanel();
secondPanel.setLayout( new GridLayout(1,5) );JPanel thirdPanel = new JPanel();
thirdPanel.setLayout( new GridLayout(1,3) );container.add( firstPanel );
container.add( secondPanel );
container.add( thirdPanel );
Container container=this.getLayout();
GridBagLayout layout=new GridBagLayout();
GridBagConstraints c=new GridBagConstrains();
JButton b1,b2//共九个JButton
c.gridx=0;
c.gridy=0;
c.fill=GridBagConstraints.VERTICAL;
container.add(c,b1);c.gridx=0;
c.gridy=1;
container.add(c,b2);
c.gridx=1;
container.add(c,b3);
.....
第三行类似,这里没装jdk,没法test,楼主可以test