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

public class Numpad
    extends Frame
{

    JButton buttons[] = new JButton[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;
    
    public Numpad(String label)
    {
	super(label);
	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[] = { "L", "*", "/", "-", "+", "E", "." };
	for (int i=0; i<buttons.length; i++)
	{
	    if (i < 10)
		buttons[i] = new JButton("" + i);
	    else
		buttons[i] = new JButton(labels[i - 10]);
	}
    }

    public static void main(String args[])
    {
	Numpad2 pad = new Numpad2("Numpad");
	pad.pack();
	pad.show();
    }

}

