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!

Stop JLabel self-resizing in GroupLayout

843806Feb 25 2009 — edited Feb 26 2009
Hi all.. I've been struggling with this for some time and would really appreciate some help...

I am using NetBeans 6.5 GUI Builder - in Free Design (Group Layout).

I have a JInternalFrame containing a JPanel which in turn contains a JLabel.

The panel and label both span the width of their containers (to the preferred distance inserts) and both have been set to be Horizontal and Vertical Resizable in the properties.

PROBLEM: When text is put into the label that it can't fit then the label grows until it can. This makes the panel grow to fit the new label width. And now the panel doesn't fit in the frame (causing scrollbars to appear if the panel has any).

QUESTION: Is there any way to make a JLabel not auto-grow in width to fit all of its text, yet still have it Horizontal Resizable in the layout properties?

i.e. Have it Resizable only in response to frame resizing etc., NOT in response to its own text content.

Thanks

Edited by: gusman on Feb 25, 2009 8:15 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2009
Added on Feb 25 2009
3 comments
746 views