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 205775 - Gridbag Layout broken
Summary: Gridbag Layout broken
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Natural Layout (show other bugs)
Version: -S1S-
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-01 13:29 UTC by johnco3
Modified: 2012-04-18 13:56 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
the desired layout of my form - customize layout screenshot & form code (120.72 KB, application/x-zip-compressed)
2011-12-01 13:29 UTC, johnco3
Details

Note You need to log in before you can comment on or make changes to this bug.
Description johnco3 2011-12-01 13:29:09 UTC
Created attachment 113701 [details]
the desired layout of my form - customize layout screenshot & form code

I tried to make a form using the ide but for some reason in the most recent build the ability to visually edit the layout is almost impossible - especially when using the GridBagLayout - forcing me to resort to customizing the weights, fills and default sizes of individual components until some magic combination of values, weights, anchors and fill widths works.  As I was in the early stages of putting the form together, I was seeing random inset values generated for the form components.   I'm trying to create a fairly complex JPanel based form.  My outermost gridbaglayout form consists of 7 child forms (each typically has a gridlayout as it contains keyboard buttons that have a grid pattern (see attached) .   I attach a screenshot of what I eventually came up with (more by luck than anything else). I also attach the CDUPanel.form and CDUPanel.java (completely generated by netbeans).  The problem is that the grid that one can typically edit in the IDE shows empty elements.

Perhaps I am missing something crucial here - but the ability to layout the ide graphically seems to have taken many steps back in the last couple of releases - the last time I recall it as being stable was back in the 6.9.x days.  Can anyone suggest what I might be doing incorrectly or should I use some other netbeans plugin like JFormDesigner (I would prefer to avoid 3rd party tools though) 

John Coffey
Comment 1 Tomas Pavek 2011-12-01 18:28:26 UTC
The attached form has the preferred size of the root panel set explicitly to 0,0 (in properties). Seems the GridBag customizer is confused by this, it displays the container in its preferred size. Also the sub-panels have the preferred size (and minimum or maximum size) set to zero. Why? I can't imagine a reason what this could be good for. (Though I can understand it's difficult to achieve a nice design with GridBagLayout.)

You should never set these 3 properties (min, pref, max size) unless you know exactly what you are doing. It's almost always wrong, especially for containers.

So when I did the following I was able to fix the form:
1) Select the root [JPanel], in properties scroll to Other Properties. Watch for properties Minimum Size, Maximum Size or Preferred Size highlighted in bold. Set all these properties to default via context menu.
2) Repeat for all all sub-panels.
3) Also set Fill layout property of jPanel5 to "Both".
(Now would be perhaps good to reconsider the desired resizing behavior of the entire layout...)


The GridBag customizer itself could possibly be fixed so it initially takes the actual size of the container in the main designer, instead of relying on the preferred size. Or allow resizing of the design area.
Comment 2 Tomas Pavek 2011-12-01 18:28:34 UTC
BTW what NetBeans version do you use?