大致代码如下:
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 );

解决方案 »

  1.   

    我在考虑这个问题用GridBagLayout也可以实现吧,不用像GridLayout这么麻烦
    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