Hi all,
I can't seem to get the gridbag layout to stop adjusting the size of cells relative to each other. I have two lists side by side, and I want them to split the display exactly 50/50 no matter what.
When neither has anything in, they are the same size. However, when one of them gets some list elements, the amount of x axis room allocated to it increases, making the display lopsided. Is there a way to stop this happening? I thought that was the point of the weights?
Here is the code (note: This isn't the exact code - I've cut several of the UI components out to keep it simple but the principle is the same)
buildConstraints(constraints, 0, 0, 1, 1, 50, 100);
constraints.fill = GridBagConstraints.BOTH;
JList list1 = new JList(nameList);
list1 .setLayoutOrientation(JList.VERTICAL);
list1 .setVisibleRowCount( -1);
JScrollPane pane1= new JScrollPane(
list1 , JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
gridbag.setConstraints(pane1, constraints);
mainPane.add(pane1);
buildConstraints(constraints, 1, 0, 1, 1, 50, 0);
constraints.fill = GridBagConstraints.BOTH;
JList list2 = new JList();
list2 .setLayoutOrientation(JList.VERTICAL);
list2 .setVisibleRowCount( -1);
JScrollPane pane2 = new JScrollPane(
list2 , JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
gridbag.setConstraints(pane2 , constraints);
mainPane.add(pane2 );