A good answer might be:

topPanel.setLayout( new GridLayout(2, 3) );       // 2 rows and 3 columns

Adding Components using GridLayout

When components are added to a container using GridLayout, they will be added in raster order (left to right, top to bottom). This is the same as with FlowLayout, except now you have control over how many cells there are per row, and how many rows. Here is the program responsible for the Frame on the previous page:

public class grid2by4 extends Frame
{
  Button L00 = new Button( "row 0 col 0" );
  Button L01 = new Button( "row 0 col 1" );
  Button L02 = new Button( "row 0 col 2" );
  Button L03 = new Button( "row 0 col 3" );
  Button L10 = new Button( "row 1 col 0" );
  Button L11 = new Button( "row 1 col 1" );
  Button L12 = new Button( "row 1 col 2" );
  Button L13 = new Button( "row 1 col 3" );
    
  grid2by4()            // constructor
  {  
    setTitle("GridLayout");
    setLayout( new GridLayout(2, 4) );       // choose the layout manager 

add( ) ;add( ) ;add( ) ;add( ) ;
add( ) ;add( ) ;add( ) ;add( ) ;
} public static void main ( String[] args ) { grid2by4 grid = new grid2by4() ; WindowQuitter wquit = new WindowQuitter(); grid.addWindowListener( wquit ); grid.setSize( 280, 200 ); grid.setVisible( true ); } }

QUESTION 10:

Decide in what order the buttons should be added (look at the previous web page to see the GUI.)

Click Here after you have answered the question