超级简单明了的JAVA计算器代码Word格式文档下载.docx

上传人:b****6 文档编号:18910239 上传时间:2023-01-02 格式:DOCX 页数:11 大小:34.59KB
下载 相关 举报
超级简单明了的JAVA计算器代码Word格式文档下载.docx_第1页
第1页 / 共11页
超级简单明了的JAVA计算器代码Word格式文档下载.docx_第2页
第2页 / 共11页
超级简单明了的JAVA计算器代码Word格式文档下载.docx_第3页
第3页 / 共11页
超级简单明了的JAVA计算器代码Word格式文档下载.docx_第4页
第4页 / 共11页
超级简单明了的JAVA计算器代码Word格式文档下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

超级简单明了的JAVA计算器代码Word格式文档下载.docx

《超级简单明了的JAVA计算器代码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《超级简单明了的JAVA计算器代码Word格式文档下载.docx(11页珍藏版)》请在冰豆网上搜索。

超级简单明了的JAVA计算器代码Word格式文档下载.docx

JButtonJ3=newJButton("

3"

JButtonJ4=newJButton("

4"

JButtonJ5=newJButton("

5"

JButtonJ6=newJButton("

6"

JButtonJ7=newJButton("

7"

JButtonJ8=newJButton("

8"

JButtonJ9=newJButton("

9"

JButtonJ0=newJButton("

0"

JButtonJe=newJButton("

="

JButtonJa=newJButton("

+"

JButtonJr=newJButton("

-"

JButtonJm=newJButton("

*"

JButtonJd=newJButton("

/"

JButtonJc=newJButton("

清除"

JButtonJpt=newJButton("

."

JTextAreashow=newJTextArea("

"

caculator(){

super("

caculator"

setLocation(200,200);

setSize(300,350);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

JPaneljp=newJPanel();

jp.setLayout(null);

jp.add(J1);

jp.add(J2);

jp.add(J3);

jp.add(J4);

jp.add(J5);

jp.add(J6);

jp.add(J7);

jp.add(J8);

jp.add(J9);

jp.add(J0);

jp.add(Je);

jp.add(Ja);

jp.add(Jr);

jp.add(Jm);

jp.add(Jd);

jp.add(Jc);

jp.add(Jpt);

J9.setBackground(Color.pink);

J8.setBackground(Color.pink);

J7.setBackground(Color.pink);

J6.setBackground(Color.pink);

J5.setBackground(Color.pink);

J4.setBackground(Color.pink);

J3.setBackground(Color.pink);

J2.setBackground(Color.pink);

J1.setBackground(Color.pink);

J0.setBackground(Color.pink);

Je.setBackground(Color.pink);

Ja.setBackground(Color.pink);

Jr.setBackground(Color.pink);

Jm.setBackground(Color.pink);

Jd.setBackground(Color.pink);

Jc.setBackground(Color.pink);

Jpt.setBackground(Color.pink);

J7.setBounds(10,70,60,50);

J8.setBounds(75,70,60,50);

J9.setBounds(140,70,60,50);

J4.setBounds(10,125,60,50);

J5.setBounds(75,125,60,50);

J6.setBounds(140,125,60,50);

J1.setBounds(10,180,60,50);

J2.setBounds(75,180,60,50);

J3.setBounds(140,180,60,50);

J0.setBounds(10,235,60,50);

Je.setBounds(75,235,60,50);

Jpt.setBounds(140,235,60,50);

Jd.setBounds(205,70,60,50);

Jm.setBounds(205,125,60,50);

Jr.setBounds(205,180,60,50);

Ja.setBounds(205,235,60,50);

Jc.setBounds(205,10,60,50);

J1.addActionListener(this);

J2.addActionListener(this);

J3.addActionListener(this);

J4.addActionListener(this);

J5.addActionListener(this);

J6.addActionListener(this);

J7.addActionListener(this);

J8.addActionListener(this);

J9.addActionListener(this);

J0.addActionListener(this);

Ja.addActionListener(this);

Jr.addActionListener(this);

Jm.addActionListener(this);

Je.addActionListener(this);

Jc.addActionListener(this);

Jpt.addActionListener(this);

jp.add(show);

show.setBackground(Color.pink);

show.setBounds(10,10,180,50);

setContentPane(jp);

}

 

@Override

publicvoidactionPerformed(ActionEvente){

if(e.getSource()==J0){

show.setText("

if(e.getSource()==J1){

if(e.getSource()==J2){

if(e.getSource()==J3){

if(e.getSource()==J4){

if(e.getSource()==J5){

}

if(e.getSource()==J6){

if(e.getSource()==J7){

if(e.getSource()==J8){

if(e.getSource()==J9){

par1=Double.parseDouble(show.getText());

if(e.getSource()==Ja){

show.setText("

if(j==0){

sum=par1;

}elseif(action==1){

sum+=par1;

setsum();

j++;

p=0;

i=0;

action=1;

}if(e.getSource()==Jr){

}elseif(action==2){

sum-=par1;

action=2;

if(e.getSource()==Jm){

}elseif(action==3){

sum*=par1;

action=3;

if(e.getSource()==Jd){

}elseif(action==4){

sum/=par1;

action=4;

if(e.getSource()==Jc){

clear();

if(e.getSource()==Jpt){

show.append("

if(e.getSource()==Je){

switch(action){

case1:

show.setText(String.valueOf(sum+=par1));

break;

case2:

show.setText(String.valueOf(sum-=par1));

case3:

show.setText(String.valueOf(sum*=par1));

case4:

show.setText(String.valueOf(sum/=par1));

j=0;

action=0;

privatevoidsetsum(){

show.setText(String.valueOf(sum));

Strings=show.getText();

}

voidclear(){

i=0;

j=0;

p=0;

sum=0;

action=0;

show.setText("

//TODOAuto-generatedmethodstub

publicstaticvoidmain(Stringargs[]){

caculatorct=newcaculator();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 其它课程

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1