This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes GridBag help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridBag help" Watch "GridBag help" New topic
Author

GridBag help

Mousa A. Rafi
Greenhorn

Joined: Jan 30, 2005
Posts: 28
Finally I'm feeling comfortable with GridBagLayout and the constraints used by GridBagConstraints. However I'm still confused with weightx and weighty. I'm not sure how they work and what good using them. The only visible effect I got is, suppose when using weighty, extra space is entered between two components when the window is enlarged vertically. I'm also confused about the values (0.0 - 1.0) used for these.

Despite its flexibility, I'm unable to do the following using GridBagLayout: I have three buttons. two below the other. I want to make the top one as long as the total length of the bottom two. That is the top button spans two columns.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Using the weight constraints is more subtle and is a key to fluid layouts that resize gracefully. The nominal range is 1 to 1.0 but some prefer to use larger, integer values.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GridBag help
 
Similar Threads
GridBagConstraints
Using GridBagLayout
GridBagLayout
GridBagLayout
Full screen