Reputation: 1351
In my Swing application I have a panel that uses a GridBagLayout. There, I have 3 columns and in one of these columns there is a JTextField. What I want is to set the width of this JTextField (using setPreferredSize() method) so that it occupies all the available space of its column.
As I understand the widths of the columns are calculated based on the weights that I've assigned to them using GridBagConstraints. I tried to subtract from the width of the panel the sum of widths of other components at the same line, but that doesn't seem to work, apparently because of different margins and insets.
So, how do I make my JTextField occupy all the available space?
Upvotes: 0
Views: 612
Reputation: 347314
Take a look at ...
These will allow you to control how a component fills a given cell and the amount of "weight" a cell is given over the others
Upvotes: 1