This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates 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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridBag Help" Watch "GridBag Help" New topic
Author

GridBag Help

bapi dhar
Ranch Hand

Joined: Mar 02, 2001
Posts: 32
Dear Friend

Having difficulty in GridBagLayout.
Please give some small examples to understand the GridBagconstraints and how to use them in different situations.
Thankyou u very much.
bapi

------------------
bapi dhar
Ranch Hand

Joined: Mar 02, 2001
Posts: 32
friends
when i would to put 2 objects
1) next to each other side by side like one one
2) one by one like this
one
one
how do u do it
thanx
bapi
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Bapi,
Here is a link about using GridBagLayout: http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html
However, if all you want to do is arrange controls as you describe here:

1) next to each other side by side like one one
2) one by one like this
one
one

GridBagLayout is more complex than necessary. In that case, just use GridLayout like this:

This code puts the buttons side-by-side like: one two.
To make them like:
one
two
just change the line from
setLayout(new GridLayout(1,2));
to
setLayout(new GridLayout(2,1));
Hope this helps.
Stephanie
bapi dhar
Ranch Hand

Joined: Mar 02, 2001
Posts: 32
dear friends

i thank u for your help.

bapi.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GridBag Help