GridLayout

The GridLayout manager tiles the enclosing container. It organizes components in a two-dimensional grid, specified in the constructor. Components are added, beginning with the top left corner, left to right, from top row to bottom row.

The code for a basic GridLayout is nearly identical to that for a FlowLayout; to provide context in the example below, some code is duplicated.

  public void init ( ){

    outerBox.setLayout ( new GridLayout ( 3, 2 ) );

    outerBox.add ( button1 );
    outerBox.add ( button2 );
    outerBox.add ( button3 );
    outerBox.add ( button4 );
    outerBox.add ( button5 );
    outerBox.add ( button6 );

  } // end init

Run the applet