posted 19 years ago
The short answer is that you can try calling setPreferredSize, however some layout managers ignore this dimension. For example, BorderLayout tries to give the component you add to the north or south its preferred height but sets its width to fit; in the east and west this is reversed and the component is given its preferred width and sets its height to fit; and finally, the center component is made to fit and its preferred size is ignored. As another example, GridBaglayout's behaviour depends on the GridBagConstraint's fill attribute.
A long time ago, I was playing around and thought a practice GUI window would look cool if *all* the buttons thoughout the window had the same width, based on the widest text. I solved this by listening to the buttons' text as a bound property, since I didn't want to hardwire in numbers.
There is no emoticon for what I am feeling!