A good answer might be:topPanel.setLayout( new GridLayout(2, 3) ); // 2 rows and 3 columns | |
Adding Components using |
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
}
public static void main ( String[] args )
{
grid2by4 grid = new grid2by4() ;
WindowQuitter wquit = new WindowQuitter();
grid.addWindowListener( wquit );
grid.setSize( 280, 200 );
grid.setVisible( true );
}
}
|
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