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

public class Numpad2
    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 Numpad2(String label)
    {
	super(label);
	createButtons();
	Panel topPanel = new Panel();
	Panel num1_9Panel = new Panel();
	Panel num0DotPanel = new Panel();
	Panel numberPanel = new Panel();
	Panel plusEnterPanel = new Panel();
	topPanel.setLayout(new GridLayout(1, 4));
	topPanel.add(buttons[LOCK]);
	topPanel.add(buttons[MULTIPLY]);
	topPanel.add(buttons[DIVIDE]);
	topPanel.add(buttons[MINUS]);
	add(topPanel, BorderLayout.NORTH);
	num1_9Panel.setLayout(new GridLayout(3, 3));
	num1_9Panel.add(buttons[7]);
	num1_9Panel.add(buttons[8]);
	num1_9Panel.add(buttons[9]);
	num1_9Panel.add(buttons[4]);
	num1_9Panel.add(buttons[5]);
	num1_9Panel.add(buttons[6]);
	num1_9Panel.add(buttons[1]);
	num1_9Panel.add(buttons[2]);
	num1_9Panel.add(buttons[3]);
	num0DotPanel.setLayout(new BorderLayout());
	num0DotPanel.add(buttons[0], BorderLayout.CENTER);
	num0DotPanel.add(buttons[DOT], BorderLayout.EAST);
	numberPanel.setLayout(new BorderLayout());
	numberPanel.add(num1_9Panel, BorderLayout.CENTER);
	numberPanel.add(num0DotPanel, BorderLayout.SOUTH);
	add(numberPanel, BorderLayout.CENTER);
	plusEnterPanel.setLayout(new GridLayout(2, 1));
	plusEnterPanel.add(buttons[PLUS]);
	plusEnterPanel.add(buttons[ENTER]);
	add(plusEnterPanel, BorderLayout.EAST);
    }
    
    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[])
    {
	Numpad pad = new Numpad("Numpad");
	pad.pack();
	pad.show();
    }

}

