Java编写的一个简单计算器,本人还比较菜,只能这样了,有点代码冗余,不能连续计算。
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class calculate extends JFrame {
JButton[] b = new JButton[10];
JPanel panel1 = new JPanel(); // 实例化面板
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JTextField answer=new JTextField(10);
JButton clear=new JButton("清除");
JButton equal=new JButton("=");
JButton point=new JButton(".");
JButton plus=new JButton("+");
JButton minus=new JButton("-");
JButton multi=new JButton("×");
JButton division=new JButton("÷");
String foreText=new String("");
String backText=new String("");
String s=new String();
String s1=new String();
Object op=new String();
Object o=new String();
double d, dFore, dBack;
int i=9;
public s