posted 20 years ago
Was wondering if someone could tell me what I'm doing wrong here - I'm trying to set the following out in a JPanel with a gridBagLayout, and everything has gone in its right place except for label_14, which instead of going below label_11, has been put on the top right of row 1 in a new column by itself. (All the labels are JLabels)
*************************************************
GridBagConstraints c = new GridBagConstraints();
GridBagLayout layout = new GridBagLayout();
// In the constructor:
this.setLayout(layout);
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.weighty = 1.0;
c.gridheight = 8;
c.fill = GridBagConstraints.BOTH;
add(label_1, c);
c.gridx = 1;
c.gridwidth = 2;
c.gridheight = 1;
add(label_2, c);
c.gridy = 2;
add(label_3, c);
c.gridy = 4;
add(label_4, c);
c.gridy = 6;
add(label_5, c);
c.gridx = 3;
c.gridy = 0;
c.gridwidth = 1;
c.gridheight = 8;
add(label_6, c);
c.gridx = 1;
c.gridy = 1;
c.gridheight = 1;
add(label_7, c);
c.gridy = 3;
add(label_8, c);
c.gridy = 5;
add(label_9, c);
c.gridy = 7;
add(label_10, c);
c.gridx = 2;
c.gridy = 1;
add(label_11, c);
c.gridy = 3;
add(label_12, c);
c.gridy = 5;
add(label_13, c);
c.gridy = 7;
add(label_14, c);
*************************************************
Can anyone tell me what I'm doing wrong, it would be much appreciated!
Thanks!