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

public class NumPadApplet
    extends Applet
{

    Button buttons[] = new Button[17];
    
    static int LOCK = 10;
    static int MULTIPLY = 11;
    static int DIVIDE = 12;
    static int MINUS = 13;
    static int PLUS = 14;
    static int ENTER = 15;
    static int DOT = 16;

    /**
     * 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();
	createButtons();
	gbc.fill = GridBagConstraints.BOTH;
	gbc.weightx = 1;
	gbc.weighty = 1;
	add(buttons[LOCK], gbc);
	add(buttons[MULTIPLY], gbc);
	gbc.gridwidth = GridBagConstraints.RELATIVE;
	add(buttons[DIVIDE], gbc);
	gbc.gridwidth = GridBagConstraints.REMAINDER;
	add(buttons[MINUS], gbc);
	gbc.gridwidth = 1;
	add(buttons[7], gbc);
	add(buttons[8], gbc);
	gbc.gridwidth = GridBagConstraints.RELATIVE;
	add(buttons[9], gbc);
	gbc.gridwidth = GridBagConstraints.REMAINDER;
	gbc.gridheight = 2;
	add(buttons[PLUS], gbc);
	gbc.gridwidth = 1;
	gbc.gridheight = 1;
	gbc.gridx = 0;
	add(buttons[4], gbc);
	gbc.gridx = 1;
	add(buttons[5], gbc);
	gbc.gridx = 2;
	add(buttons[6], gbc);
	gbc.gridx = 0;
	add(buttons[1], gbc);
	gbc.gridx = GridBagConstraints.RELATIVE;
	add(buttons[2], gbc);
	add(buttons[3], gbc);
	gbc.gridheight = 2;
	add(buttons[ENTER], gbc);
	gbc.gridwidth = 2;
	gbc.gridheight = 1;
	gbc.gridx = 0;
	add(buttons[0], gbc);
	gbc.gridwidth = 1;
	gbc.gridx = 2;
	add(buttons[DOT], gbc);
    }


    private void createButtons()
    {
	String labels[] = { "Lock", "*", "/", "-", "+", "E", "." };
	for (int i=0; i<buttons.length; i++)
	{
	    if (i < 10)
		buttons[i] = new Button("" + i);
	    else
		buttons[i] = new Button(labels[i - 10]);
	}
    }


    /**
     * 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() {
    }
}

