import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Math;
import java.awt.image.*;
public class Calculator extends JFrame implements ActionListener
{
public static final Font font=new Font("宋体",Font.PLAIN,12);
JButton plus=new JButton("+");
JButton subtract=new JButton("-");
JButton multiply=new JButton("*");
JButton divide=new JButton("/");
JButton qiuyu=new JButton("%");
JButton result=new JButton("=");
JButton negative=new JButton("+/-");
JButton point=new JButton(".");
JButton root=new JButton("sqrt");
JButton reciprocal=new JButton("1/x");
JButton backspace=new JButton("Backspace");
JButton ce=new JButton("CE");
JButton c=new JButton("C");
JButton num0,num1,num2,num3,num4,num5,num6,num7,num8,num9; //十个数字键
JButton mc,mr,ms,m; //四个看求不懂的键
JMenuItem copy,paste,standard,theme,about,me;
JTextField text;
String copycontent; //存储复制的内容
double front; //存储点击符号键之前的数据
double back; //存储点击符号键之后的数据
String symbol; //存储点击的符号键
boolean first=true; //显示文本框为初始状态时,first为true,否则为false
boolean clear=false; //判断是否点击了符号键
boolean isDesimal=false; //判断是否是小数
public Calculator()
{
setTitle("计算器");
setSize(400,300);
setLocation(500,300);
setLayout(new BorderLayout(15,15));
setResizable(false); //设置此 frame 是否可由用户调整大小
text=new JTextField("0."); //显示文本框
text.setHorizontalAlignment(JTextField.RIGHT); //从右到左显示
text.setEditable(false); //将文本框设置为用户不可编辑
text.setBackground(new Color(255, 255, 255)); //设置文本框的背景色为白色
add(text,BorderLayout.NORTH);
JPanel panel=new JPanel();
panel.setLayout(new BorderLayout(15,15));
JPanel northPanel=new JPanel();
northPanel.setLayout(new GridLayout(1,3,5,5));
panel.add(northPanel,BorderLayout.NORTH);
JPanel centerPanel=new JPanel();
centerPanel.setLayout(new GridLayout(4,3,5,5));
panel.add(centerPanel,BorderLayout.CENTER);
JPanel eastPanel=new JPanel();
eastPanel.setLayout(new GridLayout(4,2,5,5));
panel.add(eastPanel,BorderLayout.EAST);
JPanel westPanel=new JPanel();
westPanel.setLayout(new GridLayout(4,1,5,5));
panel.add(westPanel,BorderLayout.WEST);
add(panel,BorderLayout.CENTER);
backspace.setForeground(new Color(255,0,0)); //设置按钮前景色为红色
backspace.setBackground(Color.white);
backspace.addActionListener(this);
ce.setForeground(new Color(255,0,0));
ce.setBackground(Color.white);
ce.addActionListener(this);
c.setForeground(new Color(255,0,0));
c.setBackground(Color.white);
c.addActionListener(this);
northPanel.add(backspace);
northPanel.add(ce);
northPanel.add(c);
num0
=new JButton("0");
num0.setBackground(Color.white);
num0.setForeground(new Color(0,0,225));
num0.addActionListener(this);
num1=new JButton("1");
num1.setBackground(Color.white);
num1.setForeground(new Color(0,0,225));
num1.addActionListener(this);
num2=new JButton("2");
num2.setBackground(Color.white);
num2.setForeground(new Color(0,0,225));
n