Positioning components relative to top-left w/GridBagLayout

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

Positioning components relative to top-left w/GridBagLayout

Postby yaboulnaja » Tue Feb 28, 2006 2:46 pm

Hello,

My question is that when using the GridBagLayout, the components that are inserted are positioned relative to the center of the Frame. Is there a way to use the GridBagLayout such that everything is positioned relative to the top-left corner of the frame? If this is not possible, can we after designing the frame (relative to the center) shift all the components towards the top-left corner of the frame?

Thank you.
yaboulnaja
 
Posts: 2
Joined: Tue Feb 28, 2006 2:45 pm

Re: Positioning components relative to top-left w/GridBagLay

Postby Eric Clayberg » Tue Feb 28, 2006 8:17 pm

yaboulnaja wrote:My question is that when using the GridBagLayout, the components that are inserted are positioned relative to the center of the Frame. Is there a way to use the GridBagLayout such that everything is positioned relative to the top-left corner of the frame? If this is not possible, can we after designing the frame (relative to the center) shift all the components towards the top-left corner of the frame?

You can do this by adjusting the column and row weights. Add an empty column to the right of the existing columns and set its weight to 1.0 (leaving the other columns with weights of 0.0). That will shift the existing columns to the left.
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