Setting a JLabel's minimum size
797060Aug 27 2010 — edited Aug 27 2010Hello,
I have a container with a GridBag layout, and when I resize to a size wher everything fits its fine, but on the bottom of the window I have a JLabel, which can be quite large sometimes. When it is large, its minimum size is the length of the string, so when I resize its container i get some big ugly scroll bars and its contents dont get any smaller, although every other component can be much smaller.
What I would like is for the JLabel to have a minimum size (say 100 pixels) and if the window is resized less than this, introduce scroll bars, otherwise just cut off some of the text, as the label isn't very important!
I have tried loads of different stuff, the most obvious being JLabel.setMinimumSize(new Dimension(100,16)); but nothing seems to have worked, can anyone help?