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 80042 - How to create a Container Bean "really"
Summary: How to create a Container Bean "really"
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 88671 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-12 09:59 UTC by maxidea
Modified: 2012-11-08 02:50 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maxidea 2006-07-12 09:59:46 UTC
I want to create a custom JavaBean container, it's very simple, think at a 
JTabbedPane whithout the tab ... ok a JPanel with a fixed layout manager 
CardLayout.

Every time I add the container from the editor this 
method "org.netbeans.modules.form.layoutdesign.support.SwingLayoutBuilder.creat
eLayout" change my layout to GroupLayout.

Why ? i set the bean property isContainer to TRUE and containerDelegate method 
name but the editor ignore it.

is there an example ?
it's possibile to specify a constraint for dropped component ?

thanks
Comment 1 Tomas Pavek 2006-07-26 13:13:06 UTC
Your setup is correct.

Known layout in a container is always changed to GroupLayout so the user does
not need to change it manually (i.e. deal with layout managers). That's quite
important and we need to preserve this behavior.

However, I understand that in some cases the container might want to "insist" on
its default layout and basiclally not allow to change it. But there is no
standard way to recognize such containers. Components like JTabbedPane are
enumerated in the GUI builder specifically. Other containers we consider
general, i.e. as they can have any layout manager set.

There is no clear solution for this. We might either introduce some new
attribute for BeanDescriptor, or change layout to GroupLayout only for Swing
components, not for custom subclasses. Neither is perfect...

At least we should make it easy to reset the container's layout to the default
(issue 72293).
Comment 2 maxidea 2006-07-26 14:00:58 UTC
OK, I'undestand the problem but at least it's possible to verify if the layout 
manager of the JPanel (for example) is different from the default (FlowLayout) 
leave the layout manager as is ?
Comment 3 Tomas Pavek 2006-07-27 21:37:10 UTC
You mean we should compare the container's layout with default layout of the 
first Swing superclass (typically JPanel, so FlowLayout) and not change it if 
it is different? That's probably better idea than to change only Swing 
components. I'll consider it.
Comment 4 Tomas Pavek 2007-01-12 15:00:33 UTC
*** Issue 88671 has been marked as a duplicate of this issue. ***
Comment 5 Tomas Pavek 2012-11-07 13:41:44 UTC
This was improved as part of a bigger fix:
http://hg.netbeans.org/jet-main/rev/1196c3966367

The GUI builder now does not change the layout manager of custom containers (unless it is a JPanel subclass with default FlowLayout).

It is also possible to change the layout back to default (initial) - marked in the Set Layout menu, even in case it is an unknown (unsupported) layout manager.
Comment 6 Quality Engineering 2012-11-08 02:50:29 UTC
Integrated into 'main-golden', will be available in build *201211080001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/1196c3966367
User: Tomas Pavek <tpavek@netbeans.org>
Log: #215528, #212792, #80042, #70683: improved handling of custom layouts, incl. unknown, also allowing to set default layout, plus some other fixes