package accurate;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.border.TitledBorder;
import java.awt.Rectangle;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Frame1 extends JFrame {
JPanel contentPane;
int flag=0;
JTextField t1 = new JTextField();
XYLayout xYLayout1 = new XYLayout();
JTextField t2 = new JTextField();
JTextField r = new JTextField();
JLabel l1 = new JLabel();
JLabel jLabel1 = new JLabel();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
FlowLayout flowLayout1 = new FlowLayout();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
JButton jButton9 = new JButton();
JButton jButton10 = new JButton();
JButton jButton11 = new JButton();
JButton jButton12 = new JButton();
JButton jButton13 = new JButton();
JButton jButton14 = new JButton();
JButton jButton15 = new JButton();
JButton jButton16 = new JButton();
JPanel jPanel3 = new JPanel();
JButton jButton17 = new JButton();
JPanel jPanel4 = new JPanel();
TitledBorder titledBorder1 = new TitledBorder("");
JPanel jPanel5 = new JPanel();
TitledBorder titledBorder2 = new TitledBorder("");
JButton jButton18 = new JButton();
void change_num(String number){
if(flag%2==0)t1.setText(t1.getText()+number);
else t2.setText(t2.getText()+number);
}
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(460, 260));
this.setTitle("Calculator");
t2.setVerifyInputWhenFocusTarget(true);
t2.setText("");
l1.setFont(new java.awt.Font("Dialog", 0, 15));
l1.setText("+");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel1.setRequestFocusEnabled(true);
jLabel1.setText(" =");
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setMaximumSize(new Dimension(32767, 32767));
jPanel1.setLayout(flowLayout1);
jButton1.setText("3");
jButton1.setVerticalAlignment(SwingConstants.CENTER);
jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
jButton2.setSelected(false);
jButton2.setText("1");
jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this));
jButton3.setToolTipText("");
jButton3.setText("2");
jButton3.addActionListener(new Frame1_jButton3_actionAdapter(this));
jButton4.setText("4");
jButton4.addActionListener(new Frame1_jButton4_actionAdapter(this));
jButton5.setText("5");
jButton5.addActionListener(new Frame1_jButton5_actionAdapter(this));
jButton6.setText("6");
jButton6.addActionListener(new Frame1_jButton6_actionAdapter(this));
jButton7.setText("7");
jButton7.addActionListener(new Frame1_jButton7_actionAdapter(this));
jButton8.setText("8");
jButton8.addActionListener(new Frame1_jButton8_actionAdapter(this));
jButton9.setOpaque(true);
jButton9.setText("9");
jButton9.addActionListener(new Frame1_jButton9_actionAdapter(this));
jButton10.setText("0");
jButton10.addActionListener(new Frame1_jButton10_actionAdapter(this));
jButton11.setText("R");
jButton11.addActionListener(new Frame1_jButton11_actionAdapter(this));
jButton12.setText("C");
jButton12.addActionListener(new Frame1_jButton12_actionAdapter(this));
jButton13.setFont(new java.awt.Font("Dialog", 1, 12));
jButton13.setText("+");
jButton13.addActionListener(new Frame1_jButton13_actionAdapter(this));
jButton14.setFont(new java.awt.Font("Dialog", 1, 12));
jButton14.setText("-");
jButton14.addActionListener(new Frame1_jButton14_actionAdapter(this));
jButton15.setFont(new java.awt.Font("Dialog", 1, 12));
jButton15.setVerifyInputWhenFocusTarget(true);
jButton15.setText("*");
jButton15.addActionListener(new Frame1_jButton15_actionAdapter(this));
jButton16.setFont(new java.awt.Font("Dialog", 1, 12));
jButton16.setVerifyInputWhenFocusTarget(true);
jButton16.setText("/");
jButton16.addActionListener(new Frame1_jButton16_actionAdapter(this));
jPanel2.setBorder(BorderFactory.createEtchedBorder());
jButton17.setFont(new java.awt.Font("Dialog", 0, 12));
jButton17.setText("计算");
jButton17.addActionListener(new Frame1_jButton17_actionAdapter(this));
t1.setText("");
jPanel4.setBorder(titledBorder1);
jPanel5.setBorder(titledBorder2);
jPanel5.setLayout(null);
jButton18.setBounds(new Rectangle(25, 39, 73, 27));
jButton18.setText("清空");
jButton18.addActionListener(new Frame1_jButton18_actionAdapter(this));
contentPane.add(t1, new XYConstraints(52, 22, 71, -1));
contentPane.add(t2, new XYConstraints(177, 21, 67, -1));
contentPane.add(jLabel1, new XYConstraints(262, 27, 32, 13));
jPanel1.add(jButton2, null);
jPanel1.add(jButton3, null);
jPanel1.add(jButton1, null);
jPanel1.add(jButton4, null);
jPanel1.add(jButton5, null);
jPanel1.add(jButton6, null);
jPanel1.add(jButton7, null);
jPanel1.add(jButton8, null);
jPanel1.add(jButton9, null);
jPanel1.add(jButton10, null);
jPanel1.add(jButton11, null);
jPanel1.add(jButton12, null);
contentPane.add(l1, new XYConstraints(143, 23, 23, 20));
contentPane.add(jPanel2, new XYConstraints(217, 72, 215, 46));
jPanel2.add(jPanel3, null);
jPanel2.add(jButton13, null);
jPanel2.add(jButton14, null);
jPanel2.add(jButton15, null);
jPanel2.add(jButton16, null);
contentPane.add(jPanel1, new XYConstraints(40, 70, 151, 136));
contentPane.add(r, new XYConstraints(308, 22, 101, 21));
contentPane.add(jButton17, new XYConstraints(344, 163, 70, 29));
contentPane.add(jPanel5, new XYConstraints(217, 125, 215, 81));
jPanel5.add(jButton18);
contentPane.add(jPanel4, new XYConstraints(39, 8, 391, 50));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
int jButton17_actionPerformed(ActionEvent e) {
if(t1.getText()==null||t2.getText()==null)return 0;
if(l1.getText()=="+") {
r.setText(""+(Integer.parseInt(t1.getText())+Integer.parseInt(t2.getText())));}
else if(l1.getText()=="-")
r.setText(""+(Integer.parseInt(t1.getText())-Integer.parseInt(t2.getText())));
else if(l1.getText()=="*")
r.setText(""+(Double.parseDouble(t1.getText())*Double.parseDouble(t2.getText())));
else if(l1.getText()=="/")
r.setText(""+(Double.parseDouble(t1.getText())/(Integer.parseInt(t2.getText()))));
//r.setText(""+(Double.parseDouble(t1.getText())/(Integer.parseInt(t2.getText()))));
return 1;
}
void jButton13_actionPerformed(ActionEvent e) {
l1.setText("+");
flag++;
}
void jButton14_actionPerformed(ActionEvent e) {
l1.setText("-");
flag++;
}
void jButton15_actionPerformed(ActionEvent e) {
l1.setText("*");
flag++;
}
void jButton16_actionPerformed(ActionEvent e) {
l1.setText("/");
flag++;
}
void jButton2_acti
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
Calculator.rar (40个子文件)
Calculator
accurate.jpx.local 2KB
accurateW.exe 167KB
accurate.jpx.local~ 2KB
accurate.jar 18KB
bak
accurate
Frame1.java~38~ 14KB
Frame1.java~34~ 13KB
Frame1.java~31~ 13KB
Frame1.java~33~ 13KB
Frame1.java~30~ 13KB
Frame1.java~36~ 13KB
Frame1.java~32~ 13KB
Frame1.java~39~ 14KB
Main.java~1~ 1KB
Frame1.java~37~ 13KB
Frame1.java~35~ 13KB
src
accurate
Main.jbx 88B
Frame1.java 14KB
Main.java 1KB
accurate.jpx 4KB
classes
accurate
Frame1_jButton9_actionAdapter.class 662B
Frame1_jButton10_actionAdapter.class 665B
Frame1_jButton11_actionAdapter.class 665B
Frame1_jButton16_actionAdapter.class 665B
Frame1_jButton18_actionAdapter.class 665B
Frame1_jButton3_actionAdapter.class 662B
Frame1_jButton1_actionAdapter.class 662B
Frame1_jButton2_actionAdapter.class 662B
Frame1_jButton15_actionAdapter.class 665B
Frame1_jButton4_actionAdapter.class 662B
Frame1_jButton8_actionAdapter.class 662B
Frame1_jButton12_actionAdapter.class 665B
Frame1_jButton13_actionAdapter.class 665B
Frame1_jButton6_actionAdapter.class 662B
Frame1_jButton5_actionAdapter.class 662B
Main.class 1KB
Frame1_jButton14_actionAdapter.class 665B
Frame1_jButton17_actionAdapter.class 700B
Frame1_jButton7_actionAdapter.class 662B
Frame1.class 10KB
package cache
accurate.dep2 14KB
共 40 条
- 1
yangqinyao88
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1