public class CalculatorGUI {
JPanel keyPanel,textPanel,equalPanel;
JButton onebutton,twobutton,threebutton,fourbutton,fivebutton,
sixbutton,sevenbutton,eightbutton,ninebutton,zerobutton,plusbutton,
minusbutton,mulbutton,divbutton,equalbutton,leftpbutton,rightpbutton,clearbutton;
JTextField inputTF;

public CalculatorGUI(){
keyPanel = new JPanel();
textPanel = new JPanel();
equalPanel = new JPanel();
inputTF = new JTextField(10);

inputTF.addActionListener(new EqualListener());
onebutton = new JButton("1");
onebutton.setActionCommand("1");
onebutton.addActionListener(new KeyListener());
twobutton = new JButton("2");
twobutton.setActionCommand("2");
twobutton.addActionListener(new KeyListener());
threebutton = new JButton("3");
threebutton.setActionCommand("3");
threebutton.addActionListener(new KeyListener());
fourbutton = new JButton("4");
fourbutton.setActionCommand("4");
fourbutton.addActionListener(new KeyListener());
fivebutton = new JButton("5");
fivebutton.setActionCommand("5");
fivebutton.addActionListener(new KeyListener());
sixbutton = new JButton("6");
sixbutton.setActionCommand("6");
sixbutton.addActionListener(new KeyListener());
sevenbutton = new JButton("7");
sevenbutton.setActionCommand("7");
sevenbutton.addActionListener(new KeyListener());
eightbutton = new JButton("8");
eightbutton.setActionCommand("8");
eightbutton.addActionListener(new KeyListener());
ninebutton = new JButton("9");
ninebutton.setActionCommand("9");
ninebutton.addActionListener(new KeyListener());
zerobutton = new JButton("0");
zerobutton.setActionCommand("0");
zerobutton.addActionListener(new KeyListener());
leftpbutton = new JButton("(");
leftpbutton.setActionCommand("(");
leftpbutton.addActionListener(new KeyListener());
rightpbutton = new JButton(")");
rightpbutton.setActionCommand(")");
rightpbutton.addActionListener(new KeyListener());
plusbutton = new JButton("+");
plusbutton.setActionCommand("+");
plusbutton.addActionListener(new KeyListener());
minusbutton = new JButton("-");
minusbutton.setActionCommand("-");
minusbutton.addActionListener(new KeyListener());
mulbutton = new JButton("*");
mulbutton.setActionCommand("*");
mulbutton.addActionListener(new KeyListener());
divbutton = new JButton("/");
divbutton.setActionCommand("/");
divbutton.addActionListener(new KeyListener());
equalbutton = new JButton("   =   ");
equalbutton.addActionListener(new EqualListener());
clearbutton = new JButton("clear");
clearbutton.addActionListener(new ClearListener());

textPanel.add(inputTF);
keyPanel.add(sevenbutton);
keyPanel.add(eightbutton);
keyPanel.add(ninebutton);
keyPanel.add(divbutton);
keyPanel.add(fourbutton);
keyPanel.add(fivebutton);
keyPanel.add(sixbutton);
keyPanel.add(mulbutton);
keyPanel.add(leftpbutton);
keyPanel.add(zerobutton);
keyPanel.add(rightpbutton);
keyPanel.add(plusbutton);
keyPanel.add(equalbutton);
keyPanel.add(clearbutton);
//add(textPanel);
//add(keyPanel);
//add(equalPanel);
keyPanel.setLayout(new GridLayout(4,4,5,5));
}

public void display(){   
//创建窗口
JFrame myFrame = new JFrame("Calculator");
myFrame.add(textPanel);
myFrame.add(keyPanel);
myFrame.add(equalPanel);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setContentPane(new CalculatorGUI());   //这句话有问题啊  怎么改啊? 
myFrame.setPreferredSize(new Dimension(200,250));

//显示窗口
myFrame.pack();
myFrame.setVisible(true);
}public class CalculatorDemo {
public static void main(String[] args){
CalculatorGUI newdemo = new CalculatorGUI();
newdemo.display();
}
}