import java.applet.Applet;
import java.awt.*;
import javax.swing.*;

public class GridEx extends Applet {

    /**
     * Initializes the applet.  You never need to call this directly; it is
     * called automatically by the system once the applet is created.
     */
    public void init() {
	setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	//gbc.fill = GridBagConstraints.BOTH;
	gbc.weightx = 1;
	gbc.weighty = 1;
	gbc.anchor = GridBagConstraints.NORTHWEST;
	add(new JButton("Button 1"), gbc);
	gbc.anchor = GridBagConstraints.NORTH;
	add(new JButton("Button 2"), gbc);
	gbc.anchor = GridBagConstraints.NORTHEAST;
	gbc.gridwidth = GridBagConstraints.REMAINDER;
	add(new JButton("Button 3"), gbc);
	gbc.gridwidth = 1;
	gbc.anchor = GridBagConstraints.WEST;
	add(new JButton("Button 4"), gbc);
	gbc.anchor = GridBagConstraints.CENTER;
	add(new JButton("Button 5"), gbc);
	gbc.gridwidth = GridBagConstraints.REMAINDER;
	gbc.anchor = GridBagConstraints.EAST;
	add(new JButton("Button 6"), gbc);
	gbc.anchor = GridBagConstraints.SOUTHWEST;
	gbc.gridwidth = 1;
	add(new JButton("Button 7"), gbc);
	gbc.anchor = GridBagConstraints.SOUTH;
	add(new JButton("Button 8"), gbc);
	gbc.anchor = GridBagConstraints.SOUTHEAST;
	add(new JButton("Button 9"), gbc);
	setSize(300, 200);
    }

    /**
     * Called to start the applet.  You never need to call this directly; it
     * is called when the applet's document is visited.
     */
    public void start() {
    }

    /**
     * Called to stop the applet.  This is called when the applet's document is
     * no longer on the screen.  It is guaranteed to be called before destroy()
     * is called.  You never need to call this method directly
     */
    public void stop() {
    }

    /**
     * Cleans up whatever resources are being held.  If the applet is active
     * it is stopped.
     */
    public void destroy() {
    }

}

