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 202933 - In GUI builder, moving widget will cause other widgets to resize
Summary: In GUI builder, moving widget will cause other widgets to resize
Status: REOPENED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.1
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-01 18:42 UTC by theosib
Modified: 2011-10-13 03:52 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Two projects, before and after (209.85 KB, application/zip)
2011-10-02 20:05 UTC, theosib
Details
Screenshot of VisualVM (304.87 KB, image/png)
2011-10-10 02:03 UTC, theosib
Details
Thread timeline (222.82 KB, image/png)
2011-10-10 02:04 UTC, theosib
Details
Thread timeline (scrolled up to show the last few at the bottom) (221.04 KB, image/png)
2011-10-10 02:05 UTC, theosib
Details

Note You need to log in before you can comment on or make changes to this bug.
Description theosib 2011-10-01 18:42:55 UTC
Product Version = NetBeans IDE Dev (Build nbms-and-javadoc-7973-on-20110926)
Operating System = Mac OS X version 10.7.1 running on x86_64
Java; VM; Vendor = 1.6.0_26
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.1-b02-383

I'm trying to place a button so that its right side aligns with its parent panel.  I also have sub-panels (with titles) that also right-align with the same parent panel.  Whenever I try to move that button to the right edge, all of the sub-panels are resized.  I should be able to move one object without a bunch of other ones being mucked with.
Comment 1 Jan Stola 2011-10-02 18:29:03 UTC
Could you, please, attach a test-case showing the problem? Do not forget to attach both .java and .form files saved in the last good state. It would also help to attach screenshot (taken just before the drop of the button) showing the exact location of the button being added.
Comment 2 theosib 2011-10-02 20:05:10 UTC
I am attaching two complete Netbeans projects, zipped up in one archive.  The examples are based on a real project I've been working on.  Inside each project directory is two screen shots, one in the editor, one from the program running.  

NetBeansTests is the "before," where everything is fine.

NetBeansFail is the "after," where the GUI gets messed up.  The way to get this is to start with NetBeansTests and drag a JButton immediately to the right of the existing button, in order align its right edge along the right edge of jPanel2.  

When you do that, jPanel2 gets resized so that the buttons fit, but its parents do not get resized, so jPanel1 (the titled one) gets clipped off (as does the new button).

Normally, if you were to drop a button in like that, the parents would get resized properly.  But I seem to have created a hierarchy that NetBeans doesn't handle so well.

So the first problem is that resizing isn't being propagated properly.

Now, here's where it gets complicated, and I can make some more examples if you need.  In the example I attached, just deleting the new button will correct the problem.  But in my real program, those titled panels contain other widgets, and the resizing causes them to get messed up because of another bug, where Netbeans seems to forget "spacing around components" at the drop of a hat, and other weirdness involving fickleness about whether or not a widget's right edge is attached to the right edge of its parent.  So for my project, deleting the second button leaves the internals of the titled panels in a bit of a mess.
Comment 3 theosib 2011-10-02 20:05:43 UTC
Created attachment 111406 [details]
Two projects, before and after
Comment 4 Tomas Pavek 2011-10-05 15:07:30 UTC
This problem with clipping seems to have a simple cause: the JTabbedPane in the root layout has an explicit fixed width (set to 206 pixels). Absolute fixed size is always problematic in the layout, it does not allow the component to accommodate its actual size. In your case adding another button requires a sub-panel to grow, so also the tabbed pane should grow - but can't as it is set to fixed 206 pixels.

You can fix it easily by either setting the tabbed pane width to default, or make it resizable. For both see the "Layout" properties in the property sheet for selected tabbed pane. (Tip: collapse Other Properties to get the Layout properties better accessible.)

If you resize a component by mouse, it gets an absolute size set. For this reason you should never do that for fixed components like labels or buttons that need size set to default and compute their actual size based on content.

With containers it's slightly more complicated. You may notice that if you resize a sub-container like JPanel that also has a "free design" type of layout itself, its size in the parent layout is always kept as default (because the GUI builder accommodates the inner content instead). So then if anything changes in the sub-panel, it is allowed to grow in the parent layout.

This unfortunately does not work for JTabbedPane. The GUI builder does not know it could also keep it on default size (in certain situations). It's because JTabbedPane is not a general container, but has its own special layout of tabs first, then some tab can be a panel with free design. We can keep this report opened as enhancement to detect when JTabbedPane's size can be automatically set to default. (I'd expect JTabbedPane would always be _resizable_ in the layout, where the problem does not occur, so consider this less important.)

Let me know if this works for you.
Comment 5 theosib 2011-10-10 02:03:31 UTC
Created attachment 111738 [details]
Screenshot of VisualVM
Comment 6 theosib 2011-10-10 02:04:42 UTC
Created attachment 111739 [details]
Thread timeline
Comment 7 theosib 2011-10-10 02:05:06 UTC
Created attachment 111740 [details]
Thread timeline (scrolled up to show the last few at the bottom)
Comment 8 theosib 2011-10-10 02:10:10 UTC
Ok, that's annoying.  I added a comment to one bug report, and then bugzilla took me to some other bug report.  I didn't realize that and attached images to the wrong bug report.