该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
buttonBk.addActionListener(this);
buttonCe.addActionListener(this);
buttonC.addActionListener(this);
panel1.add(panel2, BorderLayout.NORTH);
panel2.setLayout(new FlowLayout(FlowLayout.RIGHT));
panel2.add(textMemory);
panel2.add(labelMemSpace);
panel2.add(buttonBk);
panel2.add(buttonCe);
panel2.add(buttonC);
panel3 = new JPanel();
panel1.add(panel3, BorderLayout.CENTER);
button = new JButton[10];
for (int i = 0; i < button.length; i++) {
button[i] = new JButton(Integer.toString(i));
button[i].setForeground(new Color(0, 0, 255));
}
buttonMC = new JButton("MC");
buttonMC.setForeground(new Color(255, 0, 0));
buttonMR = new JButton("MR");
buttonMR.setForeground(new Color(255, 0, 0));
buttonMS = new JButton("MS");
buttonMS.setForeground(new Color(255, 0, 0));
buttonMAdd = new JButton("M+");
buttonMAdd.setForeground(new Color(255, 0, 0));
buttonDot = new JButton(".");
buttonDot.setForeground(new Color(0, 0, 255));
buttonAddAndSub = new JButton("+/-");
buttonAddAndSub.setForeground(new Color(0, 0, 255));
buttonAdd = new JButton("+");
buttonAdd.setForeground(new Color(255, 0, 0));
buttonSub = new JButton("-");
buttonSub.setForeground(new Color(255, 0, 0));
buttonMul = new JButton("*");
buttonMul.setForeground(new Color(255, 0, 0));
buttonDiv = new JButton("/");
buttonDiv.setForeground(new Color(255, 0, 0));
buttonMod = new JButton("%");
buttonMod.setForeground(new Color(0, 0, 255));
buttonSqrt = new JButton("sqrt");
buttonSqrt.setForeground(new Color(0, 0, 255));
buttonDao = new JButton("1/x");
buttonDao.setForeground(new Color(0, 0, 255));
buttonEqual = new JButton("=");
buttonEqual.setForeground(new Color(255, 0, 0));
//将所有行为与监听绑定
panel3.setLayout(new GridLayout(4, 6));
panel3.add(buttonMC);
buttonMC.addActionListener(this);
panel3.add(button[7]);
button[7].addActionListener(this);
panel3.add(button[8]);
button[8].addActionListener(this);
panel3.add(button[9]);
button[9].addActionListener(this);
panel3.add(buttonDiv);
buttonDiv.addActionListener(this);
panel3.add(buttonSqrt);