布局管理器的问题!谢谢! 是一样大,而且每格都会一样大.要重新定义大小,可以先把你的控件放到一个JPanel中,可以用null或其它layout调好大小再把这个JPanel放进去 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是不是把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); }} 关于final 修饰 Integer的问题 java的时间监听问题,如何实现自动的监听呢 Static imort问题。急~~ jar问题 有关Java的一个小问题!在线等候!getSource()? 非计算机专业学JAVA多久可以找到程序员的工作? 我用数据库查询的结果,如何打印,预览? JTabbedPane隐藏显示的问题 数组问题 准备从DELPHI转向JAVA,诸位大侠,荐一本好书吧!(UP有分) 高手请教!界面的设计? 从Html文件中读取的中文字符都是问号????,高手进来指教(急,在线等)
没问题的我试了: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);
}
}