- 28
- 0
- 约8.45千字
- 约 10页
- 2019-05-16 发布于江西
- 举报
package Calculator;
import java.awt.*;
import javax.swing.*;
import java.awt.Component.*;
import java.awt.TextComponent.*;
import java.awt.event.*;
//数字按钮
class NumBtn extends JButton
{
int number;
Insets insets=new Insets(1,1,1,1);
public NumBtn(int i)
{
super(+i);
number=i;
setMargin(insets);
}
public int getNum()
{
return number;
}
}
//运算按钮
class OperBtn extends JButton
{
Insets insets=new Insets(1,1,1,1);
String operator;
public OperBtn(String str)
{
super(str);
operator=str;
setMargin(insets);
}
public String getOper()
{
return operator;
}
}
//记忆按钮
class FunBtn extends JButton
{
Insets insets=new Insets(1,1,1,1);
String function;
public FunBtn(String str)
{
super(str);
function=str;
setMargin(insets);
}
public String getFun()
{
return function;
}
}
//数学按钮
class MathBtn extends JButton
{
Insets insets=new Insets(1,1,1,1);
String math;
public MathBtn(String str)
{
super(str);
math=str;
setMargin(insets);
}
public String getMath()
{
return math;
}
}
public class Calculator extends JFrame implements ActionListener
{
Insets insets=new Insets(1,1,1,1);
NumBtn numbtn[];
OperBtn operbtn[];
FunBtn funbtn[];
MathBtn mathbtn[];
String oper[]={/,*,-,+};
String fun[]={MC,MR,MS,M+};
String math[]={sqrt,%,1/x,=};
JButton potbtn,pmbtn;
JPanel panel,part1,part2,part3;
JTextField resulttf,memtf;
JButton backspace;
JButton ce;
JButton c;
boolean isNew=true;
boolean isNextNum=false;
String newResult=null;
String newOperator=null;
String saveValue=null;
boolean isMem;
Calculator()
{
super(计算器);
//第一部分:显示结果
part1=new JPanel();
FlowLayout flowLayout1=new FlowLayout();
flowLayout1.setVgap(0);
part1.setLayout(flowLayout1);
resulttf=new JTextField(22);
resulttf.setEditable(false);
resulttf.setHorizontalAlignment(JTextField.TRAILING);
resulttf.setEnabled(true);
part1.add(resulttf);
part1.setBounds(10,25,250,45);
//第二部分:标记是否有存储值以及backspace,ce,c
part2=new JPanel();
FlowLayou
您可能关注的文档
- G网未接通原因.doc
- G网无线试题和答案.doc
- HACCP企业内审检查表.doc
- HAZOP技术应用实例解析.doc
- HDDErase,让你的SSD恢复原有的性能.doc
- HDPE管道热熔焊接技术要求.doc
- HGJ_229-91工业设备、管道防腐工程施工及验收规范.doc
- HGJ231-91_化学工业大、中型装置试车工作规范.doc
- HID 灯电子镇流器中APFC 电路的设计.doc
- Hillstone V45设备日常运维手册.docx
- 伟明环保-市场前景及投资研究报告-境内业务稳健运行,印尼市场贡献边际增量.pdf
- 桂东县法院系统招聘考试真题2025.pdf
- 贵州省黔南布依族2026年中考三模物理试题及答案.pdf
- 贵州省黔南州2026年中考语文二模试卷附答案.pdf
- 贵州省铜仁市2026年中考语文二模试卷附答案.pdf
- 2026上半年安徽事业单位联考合肥市庐江县招聘36人备考题库及一套完整答案详解.docx
- 贵州省毕节市2026年中考语文一模试卷附答案.pdf
- 贵州省贵阳市南明区2026年中考语文一模试卷附答案.pdf
- 2026上半年安徽事业单位联考合肥市庐江县招聘36人备考题库及一套参考答案详解.docx
- 贵州省贵阳市白云区2026年中考二模物理试题附答案.pdf
最近下载
- 人教版八年级历史下册知识点.doc VIP
- 2025年南昌健康职业技术学院单招(语文)测试模拟题库审定版.docx VIP
- ISO 5817-2023 焊接一钢、镰、铁及其合金的熔化焊接头(能量柬焊除外) 缺欠质量等级(中文版).pdf
- 2025年西藏自治区中考化学真题(含答案).pdf
- 【北师大版】五年级上册数学复习测试卷 (2).doc VIP
- 2025年高考真题——地理(湖南卷)含答案 .pdf VIP
- 【北师大版】五年级上册数学期末测试卷(含答案).docx VIP
- 2025年西藏中考道德与法治试卷及答案 .pdf VIP
- 2026年春八年级下册道德与法治全册知识点汇总.docx VIP
- 【北师大版】五年级数学上册《分数加减法》单元测试卷.doc VIP
原创力文档

文档评论(0)