展开全部
JAVA 计算器程序62616964757a686964616fe78988e69d8331333264643161
Cadev.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.LinkedList;
import java.text.NumberFormat;
import javax.swing.border.*;
public class Cadev extends JFrame implements ActionListener
{
Nbtn nbtn[];
Obtn obtn[];
Button dotbtn,PlusOrMinusbtn,Backspacebtn,
recbtn,equbtn,clbtn;
JPanel panel;
JTextField resultShow;
String Oper[]={"+","-","*","/"};
LinkedList link;
boolean sfcequ=false;
public Cadev()
{
super("计算器");
link=new LinkedList();
nbtn=new Nbtn[10];
for(int i=0;i<=9;i++)
{
nbtn[i]=new Nbtn(i);
nbtn[i].addActionListener(this);
}
obtn=new Obtn[4];
for(int i=0;i<4;i++)
{
obtn[i]=new Obtn(Oper[i]);
obtn[i].addActionListener(this);
}
dotbtn=new Button(".");
PlusOrMinusbtn=new Button("+/-");
equbtn=new Button("=");
recbtn=new Button("1/x");
Backspacebtn=new Button("退格");
clbtn=new Button("C");
recbtn.setForeground(Color.blue);
dotbtn.setForeground(Color.blue);
PlusOrMinusbtn.setForeground(Color.blue);
equbtn.setForeground(Color.red);
Backspacebtn.setForeground(Color.red);
clbtn.setForeground(Color.red);
dotbtn.addActionListener(this);
PlusOrMinusbtn.addActionListener(this);
equbtn.addActionListener(this);
recbtn.addActionListener(this);
Backspacebtn.addActionListener(this);
clbtn.addActionListener(this);
resultShow=new JTextField(10);
resultShow.setHorizontalAlignment(JTextField.RIGHT);
resultShow.setFont(new Font("TimesRoman",Font.PLAIN,14));
resultShow.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
resultShow.setBackground(Color.white);
resultShow.setEditable(false);
panel=new JPanel();
panel.setLayout(new GridLayout(4,5));
panel.add(nbtn[1]