File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridBag help" Watch "GridBag help" New topic

GridBag help

Mousa A. Rafi

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.
I agree. Here's the link:
subject: GridBag help
It's not a secret anymore!