private JButton s1,s2,s3,s4,s5,s6,s7, s8, s9,s0,
p1,p2,t1,t2,t3,t4,clear;
private boolean end,add,sub,mul,div;
private String str;
private double num1,num2;
public CaculatorPanel()
{
namelabel = new JLabel(" 计算器"); resultField = new
JTextField(10);
ButtonListener listener = new ButtonListener(); clear = new
JButton("clear");
clear.addActionListener(listener);
s1 = new JButton("1"); s1.addActionListener(listener); s2 = new JButton("2"); s2.addActionListener(listener); s3 = new JButton("3");
s3.addActionListener(listener); s4 = new JButton("4");
s4.addActionListener(listener); s5 = new JButton("5");
s5.addActionListener(listener); s6 = new JButton("6");
s6.addActionListener(listener); s7 = new JButton("7");
s7.addActionListener(listener); s8 = new JButton("8");
s8.addActionListener(listener); s9 = new JButton("9");
s9.addActionListener(listener); s0 = new JButton("0");
s0.addActionListener(listener); p1 = new JButton(".");
p1.addActionListener(listener); p2 = new JButton("=");
p2.addActionListener(listener); t1 = new JButton("+");
t1.addActionListener(listener); t2 = new JButton("-");
t2.addActionListener(listener); t3 = new JButton("*");
t3.addActionListener(listener); t4 = new JButton("/");
t4.addActionListener(listener);
labelPanel = new JPanel(); labelPanel.add(namelabel);
labelPanel.add(resultField); labelPanel.add(clear);
numberPanel = new JPanel(); numberPanel.setLayout(new GridLayout(4,3));
numberPanel.add(s1); numberPanel.add(s2); numberPanel.add(s3);
numberPanel.add(s4); numberPanel.add(s5);
numberPanel.add(s6);
numberPanel.add(s7);
numberPanel.add(s8);
numberPanel.add(s9);
numberPanel.add(s0); numberPanel.add(p1); numberPanel.add(p2);
toolPanel = new JPanel(); toolPanel.setLayout(new GridLayout(4,1));
toolPanel.add(t1);
toolPanel.add(t2);
toolPanel.add(t3);