I have a window that uses a GridBagLayout
as its layout. On the left side are some JComboBox
es with some labels describing what they are, and on the right, a few JPanel
s and a JLabel
giving a description of the selected item in the respective JComboBox
. Both columns have equal weights horizontally. However, the description that is a JLabel
(in bold above), although its text is in <html>
tags to make it wrap, it sets its preferred size to fit its entire length on one line, which makes it too wide, and the columns don't resize properly.
The layout is like this:
┌────────────────────┬────────────────────┐
│ JLabel │ │
├────────────────────┤ │
│ │ Description JPanel │
│ JComboBox │ │
│ │ │
├────────────────────┼────────────────────┤
│ JLabel │ │
├────────────────────┤ │
│ │ Description JPanel │
│ JComboBox │ │
│ │ │
├────────────────────┼────────────────────┤
│ JLabel │ │
├────────────────────┤ *Bothersome* │
│ │ │
│ JComboBox │ *JLabel* │
│ │ │
├────────────────────┴────────────────────┤
│ JButton (Done) │
└─────────────────────────────────────────┘
What I want to know is, how do I make the GridBagLayout
ignore the preferred size, or how can I make the two columns equal, regardless of the components in them?
Thanks in advance.