This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

GridLayout troubles

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain to me why when I run this code, I get 4 cols and 2 rows instead of 2 cols and 2 rows?




(Code tags added by Michael Morris)
[ April 23, 2004: Message edited by: Michael Morris ]
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this line

you tell the GridLayout layout manager that you want two rows and two columns. It is expecting to be handed 2 x 2 = 4 components to layout in this 2 x 2 grid. When you hand it 8 components it tries to put them in 2 rows...
Check the last paragraph in the GridLayout api for the explanation.

From this explanation, a common practice that is used in GridLayout is to specify either rows or cols and let the layout manager use the (unspecified) number of rows or cols it needs. If I want only two columns I can do:
 
    Bookmark Topic Watch Topic
  • New Topic