• Post Reply Bookmark Topic Watch Topic
  • New Topic

Grid Layout Question?  RSS feed

 
Ayan Kumar Roy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I want to ask that if I had set the layout of my Applet/Frame window GridLayout,
eg setLayout(new GridLayout(3,2));
and i had not add any panels into it.
The window has got 3x2 ie 6 grids.
But by mistake I added more than 6 components, then what will be the design?
I have tested it but found that it worked strangely.
I want to know how the layout manager will work in these situations.
Bye
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding new columns is the behavior. You are probably assuming that it should add new rows.
 
Dorothy Finkel-Laverty
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find it easier to do something like (3, 0), which will give you 3 rows, and as many columns as you need for the number of components you add to it. Or, (0, 3), which will always give you 3 columns, and as many rows as you need. If you give both parameters, GridLayout will assume that the first one (rows) is more important, and will adjust the second one to fit the actual number of components.
 
Ayan Kumar Roy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dorothy,
It worked
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!