/*
 * glLayout.java    97/07/08
 *
 * Modifications by BF Caviness
 */


import java.awt.*;

/**
 *
 * This is a corrected version of the program on pp. 123-4
 * of the book "Late Night Advanced Java."
 * There were some typographical errors that needed fixing
 * before the program would compile.  This program does not
 * produce a frame with the components that look quite as
 * uniform in size as those shown in figure 6.7 on p. 124.
 * To make the first five buttons more uniform in size
 * uncomment the one line of code below.
 *
 */

class gblLayout extends Frame
{
    gblLayout()
    {
        GridBagLayout gb = new GridBagLayout();
        GridBagConstraints gbconst;
        Button b1, b2, b3, b4, b5, b6;

        setLayout( gb );
        gbconst = new GridBagConstraints();
        b1 = new Button( "North" );
        b2 = new Button( "South" );
        b3 = new Button( "East" );
        b4 = new Button( "West" );
        b5 = new Button( "Center" );
        b6 = new Button( "BigButton" );
        add( b1 );
        add( b2 );
        add( b3 );
        add( b4 );
        add( b5 );
        add( b6 );

        gbconst.gridwidth = 1;		// Specify cell size
        gbconst.gridheight = 1;
        gbconst.gridx = 0;		// Specify cell location on grid
        gbconst.gridy = 0;
        //gbconst.fill = GridBagConstraints.BOTH;
        gb.setConstraints( b1,gbconst );
        
        gbconst.gridwidth = 1;
        gbconst.gridheight = 1;
        gbconst.gridx = 1;
        gbconst.gridy = 0;
        gb.setConstraints( b2,gbconst );
        
        gbconst.gridwidth = 1;
        gbconst.gridheight = 1;
        gbconst.gridx = 2;
        gbconst.gridy = 0;
        gb.setConstraints( b3,gbconst );
        
        gbconst.gridwidth = 1;
        gbconst.gridheight = 1;
        gbconst.gridx = 0;
        gbconst.gridy = 1;
        gb.setConstraints( b4,gbconst );
        
        gbconst.gridwidth = 1;
        gbconst.gridheight = 1;
        gbconst.gridx = 0;
        gbconst.gridy = 2;
        gb.setConstraints( b5,gbconst );
        
        gbconst.gridwidth = 2;
        gbconst.gridheight = 2;
        gbconst.gridx = 1;
        gbconst.gridy = 1;
        // Set constraint to stretch out component in both the horz. & vert.
        // directions to  fill the cell
        gbconst.fill = GridBagConstraints.BOTH;
        gb.setConstraints( b6,gbconst );

        setSize( 200,100 );
    }

    public static void main( String arg[] )
    {
        new gblLayout().show();
    }
}
