我正在尝试创建一个3x4的jpanel网格。2 by 4 is doable with gridLayout but i cannot add the cyan jpanel along the bottom. This is What I am getting when I use GridBagLayout.
Bellow是我的网格袋限制,我不知道为什么,但面板4-8是看不见的
///////////Build Top Panels///////////
buildPanel();
gc.weightx = 0.5;
gc.gridx = 0;
gc.gridy = 0;
this.add(p1,gc); // panel1
buildPanel2();
gc.gridx = 1;
gc.gridy = 0;
this.add(p2,gc); //panel2
buildPanel3();
gc.gridx = 2;
gc.gridy = 0;
this.add(p3,gc);//panel3
buildPanel4();
gc.gridx = 3;
gc.gridy = 0;
this.add(p4,gc);//panel4
buildBottomPanel();
gc.gridx = 0;
gc.gridy = 2;
this.add(b1,gc);//panel5
buildBottomPanel2();
gc.gridx = 1;
gc.gridy = 2;
this.add(b2,gc);//panel6
buildBottomPanel3();
gc.gridx = 2;
gc.gridy = 2;
this.add(b3,gc);//panel7
buildBottomPanel4();
gc.gridx = 3;
gc.gridy = 2;
this.add(b4,gc);//panel8
buildFooter();
gc.gridx = 0;
gc.gridy = 2;
gc.gridwidth = 4;
gc.fill = GridBagConstraints.HORIZONTAL;
this.add(footer,gc);//panel9发布于 2016-04-15 09:12:17
gc.gridx = 0;
gc.gridy = 2;
this.add(b1,gc);//panel5
gc.gridx = 3;
gc.gridy = 2;
this.add(b4,gc);//panel8然后你的页脚放在它们上面:
buildFooter();
gc.gridx = 0;
gc.gridy = 2;
gc.gridwidth = 4;
gc.fill = GridBagConstraints.HORIZONTAL;
this.add(footer,gc);//panel9对底部面板使用gc.gridy = 1。
https://stackoverflow.com/questions/36636251
复制相似问题