Using GridLayout
The first two arguments of the GridLayout constructor specify the number of rows of cells and the number of columns of cells, e.g:
setLayout(new GridLayout (2, 3)) ;
Optional additional arguments hgap and vgap specify the number of pixels between columns and rows:
setLayout(new GridLayout (2, 3, 10, 15 ));
The grid layout manager’s strategy is to make each cell exactly the same size, so rows and columns line up in a regular grid.