资源简介
该计算器源代码用Java实现,界面简单,精致,实现了多功能输入,支持键盘输入,记录计算过程等,非常适合初学者。NetBeans环境下实现,如果你是Eclipse环境,直接新建项目,并拷贝SRC目录下的java文件即可。
代码片段和文件信息
package mycalculator;
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author user
*/
/**
*
* @author Administrator
*/
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author user
*/
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author user
*/
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
//import java.awt.event.FocusListener;
//import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
/**
*
* @author Administrator
*/
public class BasicCalculator implements ActionListener KeyListener{
/**
* @param args the command line arguments
*/
Jframe frame;
Container container;
// JButton addBndivBnsubBntimesBndotBnflagBnequalBnsinBnbackBnclearBn;//非数字按钮共计10个
// JButton Bn0Bn1Bn2Bn3Bn4Bn5Bn6Bn7Bn8Bn9;//数字按钮共计十个
final int length = 20;
JFileChooser fc;
JButton[] Bn = new JButton[length];
JPanel panel1 panel2 panel3 panel4;
JTextField textField1;
JTextArea textArea;
JButton saveBn copyBn clearTextBn;
String operation = ““ temp = ““;
String operand1 operand2 operand3;
boolean flag = true;
int oper1 = 0 oper2 = 0 oper3 = 0;//当输入为整型
double doper1 = 0.0 doper2 = 0.0 doper3 = 0.0;//当输入为浮点型
Clipboard clipboard;
public Container go() {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
frame = new Jframe();
container = frame.getContentPane();
container.setLayout(new GridLayout(1 2 5 0));
panel1 = new JPanel();//网格左边的整体
panel3 = new JPanel();//左边面板的按键面板
// panel3.setFocusable(true);
// panel3.requestFocus();
panel1.setLayout(new BorderLayout());
textField1 = new JTextField();
textField1.addKeyListener(this);
// textField1.addFocusListener(this);
// textField1.requestFocus();
textField1.requestFocusInWindow();
textField1.setHorizontalAlignment(JTextField.RIGHT);
panel1.add(textField1 BorderLayout.NORTH);
// panel1.setVisible(false);
//设计网格布局,并且初始化网格上的每个按钮
panel3.setLayout(new GridLayout(4 5));
Bn[0] = new JButton(“1“);
Bn[0].addKeyListener(this);
Bn[0].setActionCommand(“digit“);
Bn[1] = new JButton(“2“);
Bn[1].setActionCommand(“digit“);
Bn[2] = new JButton(“3“);
Bn[2].setActionCommand(“digit“
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7539 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator\BasicCalculator.class
文件 2746 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator\MiddleCalculator$1.class
文件 1226 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator\MiddleCalculator$2.class
文件 866 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator\MiddleCalculator$3.class
文件 7777 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator\MiddleCalculator.class
文件 3365 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator\ScientificCalculator.class
文件 3731 2013-07-01 09:18 MyCalculator\MyCalculator\build.xm
文件 24966 2013-07-01 11:12 MyCalculator\MyCalculator\dist\MyCalculator.jar
文件 1451 2013-07-01 11:12 MyCalculator\MyCalculator\dist\README.TXT
文件 85 2013-06-24 15:07 MyCalculator\MyCalculator\manifest.mf
文件 34077 2013-07-01 09:18 MyCalculator\MyCalculator\nbproject\build-impl.xm
文件 455 2013-07-01 09:18 MyCalculator\MyCalculator\nbproject\genfiles.properties
文件 111 2013-07-01 09:18 MyCalculator\MyCalculator\nbproject\private\private.properties
文件 309 2013-07-01 08:49 MyCalculator\MyCalculator\nbproject\private\private.xm
文件 1975 2013-06-24 15:07 MyCalculator\MyCalculator\nbproject\project.properties
文件 520 2013-06-24 15:07 MyCalculator\MyCalculator\nbproject\project.xm
文件 14598 2013-07-01 11:12 MyCalculator\MyCalculator\src\mycalculator\BasicCalculator.java
文件 15468 2013-07-01 11:12 MyCalculator\MyCalculator\src\mycalculator\MiddleCalculator.java
文件 3340 2013-07-01 10:01 MyCalculator\MyCalculator\src\mycalculator\ScientificCalculator.java
目录 0 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes\mycalculator
目录 0 2013-07-01 11:12 MyCalculator\MyCalculator\build\classes
目录 0 2013-06-24 17:32 MyCalculator\MyCalculator\nbproject\private
目录 0 2013-07-01 11:08 MyCalculator\MyCalculator\src\mycalculator
目录 0 2013-07-01 11:12 MyCalculator\MyCalculator\build
目录 0 2013-07-01 11:12 MyCalculator\MyCalculator\dist
目录 0 2013-06-24 15:07 MyCalculator\MyCalculator\nbproject
目录 0 2013-06-24 15:07 MyCalculator\MyCalculator\src
目录 0 2013-06-24 15:07 MyCalculator\MyCalculator\test
目录 0 2013-07-01 11:12 MyCalculator\MyCalculator
目录 0 2013-07-01 09:18 MyCalculator
............此处省略3个文件信息
- 上一篇:MPI及其JAVA实现
- 下一篇:java单功能流水线调度
相关资源
- JAVA计算器小程序多进制计算、转换
- java使用后缀表达式实现计算器
- 一个简单的java计算器实验报告
- java科学计算器源码及课设报告
- Java计算器130031
- Java计算器实现代码
- JAVA计算器计算器JAVA计算器计算器
- JAVA计算器科学型+标准型
- JAVA计算器(含有优先级的判定)
- 带括号和小数点的java计算器程序
- java计算器源代码及其实验报告
- 利用网格布局写的一个java计算器
- java计算器的实现--ppt课件
- java计算器源代码
- java简易计算器四则运算、三角函数、
- java计算器
- java计算器,带历史记录功能
- java计算器源码
- JAVA做的计算器小程序实现简单的功能
- 基于java的计算器源程序+代码+设计报
- java计算器源代码
评论
共有 条评论