是一样大,而且每格都会一样大.
要重新定义大小,可以先把你的控件放到一个JPanel中,
可以用null或其它layout调好大小再把这个JPanel放进去

解决方案 »

  1.   

    是不是把jPanel放到GridLayout的网格里面去了?
    没问题的我试了:public class Panel2 extends JPanel {
        private GridLayout gridLayout1 = new GridLayout(2,2);
        private JPanel jPanel1 = new JPanel();
        private JPanel jPanel2 = new JPanel();
        private JButton jButton1 = new JButton();
        private JButton jButton2 = new JButton();
        private JPanel jPanel3 = new JPanel();
        private JCheckBox jCheckBox1 = new JCheckBox();
        private JPanel jPanel4 = new JPanel();
        private JCheckBox jCheckBox2 = new JCheckBox();    public Panel2() {
            try {
                jbInit();
            }
            catch(Exception ex) {
                ex.printStackTrace();
            }
        }
        void jbInit() throws Exception {
            this.setLayout(gridLayout1);
            jButton1.setText("jButton1");
            jButton2.setText("jButton2");
            jCheckBox1.setText("jCheckBox1");
            jCheckBox2.setText("jCheckBox2");
            this.add(jPanel1, null);
            jPanel1.add(jButton1, null);
            this.add(jPanel4, null);
            jPanel4.add(jCheckBox2, null);
            this.add(jPanel3, null);
            jPanel3.add(jCheckBox1, null);
            this.add(jPanel2, null);
            jPanel2.add(jButton2, null);
        }
    }