J
Jason Cavett
I'm a little confused about GridBagLayout. I've used it quite a bit,
and it works great about 95% of the time. I recently ran into this
problem with two different components, and I am wondering if there's a
simple solution.
I have a bunch of components in a JPanel. Let's say the JPanel is a
certain height and width. All the components have a preferred size
(but not max or min explicitly defined) and everything looks great.
Because of various restrictions previously, the width of the JPanel
was way bigger than it needed to be. So, I recently reduced with
width (just had to change a static final int at the top of the source
code). I fire up the GUI again, and everything looks great...except
one of the components (a JTextBox in one GUI and a JComboBox in
another GUI) are now ~1px in width. Every other component looks
perfectly fine.
In fact, what's even more weird is that, in the case of the JComboBox,
I changed the height. And, now, the JComboBox is the width of the
longest piece of text inside the box rather than following its
preferred size.
I have to admit, I can't figure this out for the life of me. If I set
minimumSize, it looks fine, but I'd like to understand what is
happening.
Thanks for any help to this frustrating problem!
and it works great about 95% of the time. I recently ran into this
problem with two different components, and I am wondering if there's a
simple solution.
I have a bunch of components in a JPanel. Let's say the JPanel is a
certain height and width. All the components have a preferred size
(but not max or min explicitly defined) and everything looks great.
Because of various restrictions previously, the width of the JPanel
was way bigger than it needed to be. So, I recently reduced with
width (just had to change a static final int at the top of the source
code). I fire up the GUI again, and everything looks great...except
one of the components (a JTextBox in one GUI and a JComboBox in
another GUI) are now ~1px in width. Every other component looks
perfectly fine.
In fact, what's even more weird is that, in the case of the JComboBox,
I changed the height. And, now, the JComboBox is the width of the
longest piece of text inside the box rather than following its
preferred size.
I have to admit, I can't figure this out for the life of me. If I set
minimumSize, it looks fine, but I'd like to understand what is
happening.
Thanks for any help to this frustrating problem!