import java.applet.Applet ;
import java.awt.* ;
import javax.swing.* ;
import javax.swing.border.* ;
import javax.swing.event.* ;
/**
 * GridLayoutDemo
 *
 * @author T. K. Rogers
 * @version 1.0
 */

public class GridLayoutDemo extends Applet  {
    JButton start1 ;  // Note that memory is allocated later in
    JButton start2 ;  // the program for these two objects.
    JButton start3 = new JButton ( "start3" ) ;
    JButton start4 = new JButton ( "start4" ) ;
    JButton start5 = new JButton ( "start5" ) ;
    JButton start6 = new JButton ( "start6" ) ;
   
    public void init ( ) {
        setLayout ( new GridLayout ( 3, 2 ) ) ; // 3 = rows, 2 = columns
       
        start1 = new JButton ( this.output ( "START1" ) ) ; // These two lines show that the
        start2 = new JButton ( output ( "START2" ) ) ;        // "this" operator is optional when
                                                                                     // calling an instance method
                                                                                     // inside its own class.

        add ( start1 ) ; // Grid layout starts in
        add ( start2 ) ; // the upper left cell and
        add ( start3 ) ; // loads objects left to
        add ( start4 ) ; // right until a row is filled
        add ( start5 ) ; // then moves downward to the
        add ( start6 ) ; // next row.
    }
   
    public String output ( String name ) {  // instance method
        return buttonLable ( name ) ;          // An instance method calling
                                                              // a static method in the same class.
    }
   
    public static String buttonLable ( String nameStatic ) {  // static method
        return nameStatic;  
    } 
}