posted 21 years ago
Hello Shah,

This is what I could find out.

The GridLayout class has three constructors.

1. GridLayout()

2. GridLayout(int Rows, int Columns)

3. GridLayout(int Rows, int Columns, int Hrgap, int Vrgap)

Constructor 1 is equivalent to 1 row and 0 columns.

In constructors 2 and 3, either rows or columns can be zero but not both.

According to Khalid Mughal components are added left to right, top to bottom (row-major) in the container. The geometry of the grid is determined by the non-zero parameter (row or column) and the number of components added.

So

1. if the number of rows is non-zero then the number of columns is ignored and the JVM figures out the number of columns based on the number of components being added to the container

Example. if rows = 4 and 3 components are being added then you will see a gid layout with one column with 3 components and a blank row at the bottom

Example. if rows = 4 and 9 components are being added number 1 thru 9 then you will a grid with 4 rows and three columns and the components will be filled row first

1 2 3

4 5 6

7 8 9

blank row

2. if number of rows is zero and number of columns is non-zero then the number of columns stay fixed and number of rows will depend upon the number of components being added

Example. if columns = 2 and 3 components are added

then two rows will be needed and the components are added row-major so you will see

1 2

3 blank

Example if columns = 4 and 2 components are added then you will see

1 2 blank blank

3. If both rows and columns are specified then the number of rows stays fixed and number of columns is figured out based on number of components added.

I hope I got this one right

Thanks