This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 140976 - Label with long text too wide to fit inside the container
Summary: Label with long text too wide to fit inside the container
Status: RESOLVED INVALID
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Natural Layout (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-21 12:35 UTC by Andrei Badea
Modified: 2008-07-23 16:53 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Initial state (1.88 KB, image/png)
2008-07-21 12:35 UTC, Andrei Badea
Details
Label incorrectly resized (2.11 KB, image/png)
2008-07-21 12:36 UTC, Andrei Badea
Details
Expected behavior (2.23 KB, image/png)
2008-07-21 12:36 UTC, Andrei Badea
Details
JFrame source code and .form file (2.24 KB, application/x-compressed)
2008-07-21 12:37 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Badea 2008-07-21 12:35:22 UTC
Have a JFrame with a label whose width entirely fits inside the frame. Set the label's text property to a string longer
than the frame width. The label will resize to fit the whole string, but it won't fit inside the frame anymore (being
wider than the frame), and worse, it will cause other components in the frame to be resized this way too. See the
attached images.
Comment 1 Andrei Badea 2008-07-21 12:35:52 UTC
Created attachment 65112 [details]
Initial state
Comment 2 Andrei Badea 2008-07-21 12:36:10 UTC
Created attachment 65113 [details]
Label incorrectly resized
Comment 3 Andrei Badea 2008-07-21 12:36:30 UTC
Created attachment 65114 [details]
Expected behavior
Comment 4 Andrei Badea 2008-07-21 12:37:21 UTC
Created attachment 65115 [details]
JFrame source code and .form file
Comment 5 Jan Stola 2008-07-21 17:20:05 UTC
I am sorry, I don't see any problem in GUI builder using your test case. The description shows that you designed the 
layout of your container in one way, but you want to behave it differently. The GUI builder cannot know that. You 
should change the layout to meet your needs.

The label is added as non-resizable component e.g. component that keeps its preferred size and doesn't resize when the 
size of the container is changed. When you change the text of the label then its preferred size is changed (increased). 
Hence, the label becomes wider.

The "expected behavior" screenshot shows that you want another behaviour. You want the text of your label to stop few 
pixels before the right edge of the container e.g. you want your label to be resizable. You don't want it to honor its 
preferred size. You can easily achieve that - just drag the right edge of the label and drop it aligned with the right 
edge of the JComboBox.

Unfortunately, you have to do one more change. By default, we generate code that doesn't allow resizable labels to 
shrink below its minimum size (usually equal to preferred size) - while this is the required behaviour in most cases, 
it is not true in your case. So, the last change you have to do is to change the minimum size to (0,0). Now the layout 
should work as you expected.
Comment 6 Andrei Badea 2008-07-23 16:53:15 UTC
Thank you for the explanation.