Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Setting a JLabel's minimum size

797060Aug 27 2010 — edited Aug 27 2010
Hello,

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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2010
Added on Aug 27 2010
4 comments
845 views