Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GridBag Help

 
bapi dhar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear friends

i thank u for your help.

bapi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic