• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using GridLayout

 
Yingie Pitts
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started to learn Swing. I am arranging a serious of radio buttons and a OK button on a JPanel using GridLayout (0, 1). The problem is that the OK Button always occupied the entire grid. I know this is how GridLayout works. If I use FlowLayout, the radio buttons will not be arranged neatly. GridBagConstraints and GridBagLayout are too complicated for me at this time. Does any one know how can I customize the size of OK button using GridLayout?

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you show us some specific code to criticize. Using GridLayout(0,1) should stack your components one on top the other, all at the same size.
 
ib idris
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
GridLayout is like a table you specify the number of rows and columns.
http://galileo.spaceports.com/~ibidris/
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also pass 0 for either the number of rows OR the number of columns. If you pass zero for the number of rows, then GridLayout divides the number of components by the number of columns and figures out the number of rows -- and vice versa.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!