How to - Custom Container with default Layout

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

How to - Custom Container with default Layout

Postby sommermartin » Wed Oct 03, 2007 2:48 pm

How would one create and use a custom container that specifies a particular LayoutManager with specific settings.

Specifically I am thinking of extending JPanel and setting a Form LayoutManager with specific columns and rows.

thank you much,

Martin
sommermartin
 
Posts: 8
Joined: Wed Oct 03, 2007 12:23 pm

Re: How to - Custom Container with default Layout

Postby Eric Clayberg » Thu Oct 04, 2007 4:44 am

sommermartin wrote:How would one create and use a custom container that specifies a particular LayoutManager with specific settings.

Create a JPanel subclass and assign a layout manager to it. That layout will then be used if the panel is used in another window. This works for any simple Swing layout manager that does not have any complex internal state associated with it

sommermartin wrote:Specifically I am thinking of extending JPanel and setting a Form LayoutManager with specific columns and rows.

This will not work for the JGoodies FormLayout. That layout is too complex and has too much local state info associate with it which is not visible to the outer window.

You can assign a FormLayout to a custom panel, but you need to do it in the context in which it is being used (e.g., in the same scope in which the widgets will be added).
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

could I

Postby sommermartin » Tue Oct 09, 2007 8:45 am

Eric,

thank you very much.

Would it be possible to achieve it using creating a jvt for a custom panel (is it possible)?

Or would I be better off creating an eclipse pluggin that creates a wizard flow?

thank you,

Martin
sommermartin
 
Posts: 8
Joined: Wed Oct 03, 2007 12:23 pm

Re: could I

Postby Eric Clayberg » Tue Oct 09, 2007 11:06 am

sommermartin wrote:Would it be possible to achieve it using creating a jvt for a custom panel (is it possible)?

I don't see how that would make any difference. The only important thing here is that the layout must be created/defined in the same scope in which the widgets will be added.

sommermartin wrote:Or would I be better off creating an eclipse pluggin that creates a wizard flow?

I'm not even sure what you mean here.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest