Stopping the stretchiness of JTextAreas and JTables in a GridBagLayout
Posted on 2002-07-11
Wonder if someone could help me here please?
In the app I'm writing, I have a few dialogues that have GridBagLayouts on them. Some of the controls in these GridBagLayouts are JTextAreas and JTables enclosed in JScrollPanes.
The first problem I have is with the JTable. If the table is empty the GridBagLayout is displayed narrower than the dimensions I have assigned to it, but as soon as you add a row to the table, the JTable stretches wider to fill the unoccupied space which in turn pushes the other controls and panel to the right.
The second problem is with the JTextArea. If I type into this control, and hold a key down, the text doesn't wrap to the next line, and once again the control stretches to fill the unoccupied space, thus sqaushing up all the controls to it's left.
Now I understand that by setting the weight of a column to 0 in a GridBagLayout constraint, the column doesn't stretch, but I need to specify a column percentage for the JTable and JTextArea controls because other columns exist within each GridBagLayout too.
Can someone help me here please? Thanks