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 ]
posted 11 years ago
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: