资源简介
虽然功能简单了些。不过含有优先权的判定。比较方便了!使用了正则表达式。
代码片段和文件信息
package com.yilong;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Font;
import java.awt.frame;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Calculate extends Jframe implements ActionListener {
public static final int WIDTH = 400;
public static final int HEIGHT = 500;
public static final int LOCATION_X = 300;
public static final int LOCATION_Y = 200;
JPanel display = new JPanel();
JPanel select = new JPanel();
JTextField check = new JTextField();
JTextField in = new JTextField();
JButton num0 = new JButton(“0“);
JButton num1 = new JButton(“1“);
JButton num2 = new JButton(“2“);
JButton num3 = new JButton(“3“);
JButton num4 = new JButton(“4“);
JButton num5 = new JButton(“5“);
JButton num6 = new JButton(“6“);
JButton num7 = new JButton(“7“);
JButton num8 = new JButton(“8“);
JButton num9 = new JButton(“9“);
JButton add = new JButton(“+“);
JButton minus = new JButton(“-“);
JButton multiply = new JButton(“*“);
JButton divide = new JButton(“/“);
JButton clear = new JButton(“清空“);
JButton equal = new JButton(“=“);
Color standardColor = new Color(190 240 200);
{
check.setFont(new Font(null Font.BOLD + Font.ITALIC 12));
check.setEditable(false);
check.setBackground(standardColor);
in.setFont(new Font(null Font.BOLD 22));
in.setText(“0.0“);
in.setEditable(false);
in.setBackground(standardColor);
in.setHorizontalAlignment(JTextField.RIGHT);
num0.setFont(new Font(null Font.BOLD 30));
num1.setFont(new Font(null Font.BOLD 30));
num2.setFont(new Font(null Font.BOLD 30));
num3.setFont(new Font(null Font.BOLD 30));
num4.setFont(new Font(null Font.BOLD 30));
num5.setFont(new Font(null Font.BOLD 30));
num6.setFont(new Font(null Font.BOLD 30));
num7.setFont(new Font(null Font.BOLD 30));
num8.setFont(new Font(null Font.BOLD 30));
num9.setFont(new Font(null Font.BOLD 30));
add.setFont(new Font(null Font.BOLD 30));
minus.setFont(new Font(null Font.BOLD 30));
multiply.setFont(new Font(null Font.BOLD 30));
num0.setFont(new Font(null Font.BOLD 30));
divide.setFont(new Font(null Font.BOLD 30));
equal.setFont(new Font(null Font.BOLD 30));
clear.setFont(new Font(null Font.BOLD 30));
}
boolean isClear = true;
boolean in_isClear = true;
boolean is_Result = false;
private int result;
String input;
enum Symbol {
Add Minus Multiply Divide Null
}
Symbol operation = Symbol.Null;
Calculate(String name) {
super(name);
this.setBounds(this.LOCATION_X this.LOCATION_Y this.WIDTH this.HEIGHT);
this
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 232 2009-11-14 08:44 JAVA计算器\.classpath
文件 388 2009-11-14 08:44 JAVA计算器\.project
文件 699 2009-11-19 00:11 JAVA计算器\bin\com\yilong\Calculate$1.class
文件 1214 2009-11-19 00:11 JAVA计算器\bin\com\yilong\Calculate$Symbol.class
文件 6265 2009-11-19 00:11 JAVA计算器\bin\com\yilong\Calculate.class
文件 4339 2009-11-19 00:11 JAVA计算器\bin\com\yilong\Multi_Operation.class
文件 7617 2009-11-30 19:17 JAVA计算器\Calculator.jar
文件 7156 2009-11-14 16:22 JAVA计算器\src\com\yilong\Calculate.java
文件 5201 2009-11-14 16:33 JAVA计算器\src\com\yilong\Multi_Operation.java
文件 283136 2009-11-28 00:56 JAVA计算器\实验三.doc
目录 0 2010-02-02 09:31 JAVA计算器\bin\com\yilong
目录 0 2010-02-02 09:31 JAVA计算器\src\com\yilong
目录 0 2010-02-02 09:31 JAVA计算器\bin\com
目录 0 2010-02-02 09:31 JAVA计算器\src\com
目录 0 2010-02-02 09:31 JAVA计算器\bin
目录 0 2010-02-02 09:31 JAVA计算器\src
目录 0 2010-02-02 09:31 JAVA计算器
----------- --------- ---------- ----- ----
316247 17
评论
共有 条评论