package keyconculator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
public class KeyCalculator extends JFrame{
private static final long serialVersionUID = 1L;
JPanel contentPane;
JTextField jTextField1 = new JTextField("0");
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
JButton jButton9 = new JButton();
JButton jButton10 = new JButton();
JButton jButton11 = new JButton();
JButton jButton12 = new JButton();
JButton jButton13 = new JButton();
JButton jButton14 = new JButton();
JButton jButton15 = new JButton();
JButton jButton16 = new JButton();
JButton jButton17 = new JButton();
JButton jButton18 = new JButton();
JButton jButton19 = new JButton();
JButton jButton20 = new JButton();
boolean able_Input=true;
boolean Ctrl=false;
String str=null,str2=null;
String oper=null,old_oper=null;
Strr BigNum1=new Strr();
Strr BigNum2=new Strr();
Arithmetic Calculators=new Arithmetic();
Clipboard clipboard=Toolkit.getDefaultToolkit().getSystemClipboard();
//添加KeyCalculator类构造函数
public KeyCalculator()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
//设计计算器的外观和行为
private void jbInit() throws Exception
{
this.setLocation(500,300);
//this.setLocale(java.util.Locale.getDefault());
this.setSize(new Dimension(245, 295));
this.setTitle("计算器");
this.addKeyListener(new KeyCalculator_this_keyAdapter(this));
jTextField1.setEditable(false);
jTextField1.setFocusable(true);
jTextField1.setBackground(Color.white);
jTextField1.setBounds(new Rectangle(23, 12, 200, 21));
jTextField1.setHorizontalAlignment(JTextField.RIGHT);
jButton1.setBounds(new Rectangle(23, 103, 47, 25));
jButton1.setText("9");
jButton1.addActionListener(new KeyCalculator_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(73, 103, 46, 25));
jButton2.setText("8");
jButton2.addActionListener(new KeyCalculator_jButton2_actionAdapter(this));
jButton3.setBounds(new Rectangle(123, 103, 46, 25));
jButton3.setText("7");
jButton3.addActionListener(new KeyCalculator_jButton3_actionAdapter(this));
jButton4.setBounds(new Rectangle(173, 200, 50, 25));
jButton4.setToolTipText("");
jButton4.setText("+");
jButton4.setForeground(Color.red);
jButton4.addActionListener(new KeyCalculator_jButton4_actionAdapter(this));
jButton5.setBounds(new Rectangle(23, 135, 46, 25));
jButton5.setText("6");
jButton5.addActionListener(new KeyCalculator_jButton5_actionAdapter(this));
jButton6.setBounds(new Rectangle(73, 135, 46, 25));
jButton6.setText("5");
jButton6.addActionListener(new KeyCalculator_jButton6_actionAdapter(this));
jButton7.setBounds(new Rectangle(123, 135, 46, 25));
jButton7.setForeground(Color.black);
jButton7.setText("4");
jButton7.addActionListener(new KeyCalculator_jButton7_actionAdapter(this));
jButton8.setBounds(new Rectangle(173, 168, 50, 25));
jButton8.setText("-");
jButton8.setForeground(Color.red);
jButton8.addActionListener(new KeyCalculator_jButton8_actionAdapter(this));
jButton9.setBounds(new Rectangle(23, 168, 46, 25));
jButton9.setHorizontalAlignment(SwingConstants.CENTER);
jButton9.setText("3");
jButton9.addActionListener(new KeyCalculator_jButton9_actionAdapter(this));
jButton10.setBounds(new Rectangle(73, 168, 46, 25));
jButton10.setText("2");
jButton10.addActionListener(new KeyCalculator_jButton10_actionAdapter(this));
jButton11.setBounds(new Rectangle(123, 168, 46, 25));
jButton11.setForeground(Color.black);
jButton11.setText("1");
jButton11.addActionListener(new KeyCalculator_jButton11_actionAdapter(this));
jButton12.setBounds(new Rectangle(173, 135, 50, 25));
jButton12.setVerifyInputWhenFocusTarget(true);
jButton12.setText("*");
jButton12.setForeground(Color.red);
jButton12.addActionListener(new KeyCalculator_jButton12_actionAdapter(this));
jButton13.setBounds(new Rectangle(23, 200, 46, 25));
jButton13.setToolTipText("");
jButton13.setText("0");
jButton13.addActionListener(new KeyCalculator_jButton13_actionAdapter(this));
jButton14.setBounds(new Rectangle(73, 200, 46, 25));
jButton14.setToolTipText("");
jButton14.setText("+/-");
jButton14.setFont(new java.awt.Font("Dialog", 0, 10));
jButton14.addActionListener(new KeyCalculator_jButton14_actionAdapter(this));
jButton15.setBounds(new Rectangle(123, 200, 46, 25));
jButton15.setToolTipText("");
jButton15.setText(".");
jButton15.addActionListener(new KeyCalculator_jButton15_actionAdapter(this));
jButton16.setBounds(new Rectangle(173, 103, 50, 25));
jButton16.setText("/");
jButton16.setForeground(Color.red);
jButton16.addActionListener(new KeyCalculator_jButton16_actionAdapter(this));
jButton17.setBounds(new Rectangle(23, 39, 96, 25));
jButton17.setText("Backspace");
jButton17.setForeground(Color.red);
jButton17.setFont(new java.awt.Font("Dialog", 0, 11));
jButton17.addActionListener(new KeyCalculator_jButton17_actionAdapter(this));
jButton18.setBounds(new Rectangle(123, 39, 100, 25));
jButton18.setSelected(false);
jButton18.setText("CE");
jButton18.setForeground(Color.red);
jButton18.setFont(new java.awt.Font("Dialog", 0, 11));
jButton18.addActionListener(new KeyCalculator_jButton18_actionAdapter(this));
jButton19.setBounds(new Rectangle(23, 71, 96, 25));
jButton19.setVerifyInputWhenFocusTarget(true);
jButton19.setText("C");
jButton19.setForeground(Color.red);
jButton19.setFont(new java.awt.Font("Dialog", 0, 11));
jButton19.addActionListener(new KeyCalculator_jButton19_actionAdapter(this));
jButton20.setBounds(new Rectangle(123, 71, 100, 25));
jButton20.setText("=");
jButton20.setForeground(Color.red);
jButton20.addActionListener(new KeyCalculator_jButton20_actionAdapter(this));
contentPane=(JPanel)this.getContentPane();
contentPane.setLayout(null);
contentPane.setForeground(Color.black);
contentPane.add(jTextField1, null);
contentPane.add(jButton1, null);
contentPane.add(jButton2, null);
contentPane.add(jButton3, null);
contentPane.add(jButton4, null);
contentPane.add(jButton5, null);
contentPane.add(jButton6, null);
contentPane.add(jButton7, null);
contentPane.add(jButton8, null);
contentPane.add(jButton9, null);
contentPane.add(jButton10, null);
contentPane.add(jButton11, null);
contentPane.add(jButton12, null);
contentPane.add(jButton13, null);
contentPane.add(jButton14, null);
contentPane.add(jButton15, null);
contentPane.add(jButton16, null);
contentPane.add(jButton17, null);
contentPane.add(jButton18, null);
contentPane.add(jButton19, null);
contentPane.add(jButton20, null);
jButton1.setFocusable(false);
jButton2.setFocusable(false);
jButton3.setFocusable(false);
jButton4.setFocusable(false);
jButton5.setFocusable(false);
jButton6.setFocusable(false);
jButton7.setFocusable(false);
jButton8.setFocusable(false);
jButton9.setFocusable(false);
jButton11.setFocusable(false);
jButton12.setFocusable(false);
jButton13.setFocusable(false);
jButton14.setFocus