计算器java程序文档格式.docx

上传人:b****8 文档编号:22511181 上传时间:2023-02-04 格式:DOCX 页数:35 大小:20.81KB
下载 相关 举报
计算器java程序文档格式.docx_第1页
第1页 / 共35页
计算器java程序文档格式.docx_第2页
第2页 / 共35页
计算器java程序文档格式.docx_第3页
第3页 / 共35页
计算器java程序文档格式.docx_第4页
第4页 / 共35页
计算器java程序文档格式.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

计算器java程序文档格式.docx

《计算器java程序文档格式.docx》由会员分享,可在线阅读,更多相关《计算器java程序文档格式.docx(35页珍藏版)》请在冰豆网上搜索。

计算器java程序文档格式.docx

this.setResizable(false);

text=newTextArea("

"

2,40,TextArea.SCROLLBARS_NONE);

text.setEditable(true);

text.setFont(newFont("

宋体"

Font.BOLD,16));

this.add(text);

text.addTextListener(this);

JPanelpanel=newJPanel(newGridLayout(1,2));

this.add(panel);

JPanelpanel_radiobutton_1=newJPanel(newGridLayout(2,2));

panel.add(panel_radiobutton_1);

ButtonGroupbuttongroup_1=newButtonGroup();

radiobutton_decimal=newJRadioButton("

十进制"

true);

radiobutton_decimal.addActionListener(this);

buttongroup_1.add(radiobutton_decimal);

panel_radiobutton_1.add(radiobutton_decimal);

radiobutton_binary=newJRadioButton("

二进制"

radiobutton_binary.addActionListener(this);

buttongroup_1.add(radiobutton_binary);

panel_radiobutton_1.add(radiobutton_binary);

radiobutton_octal=newJRadioButton("

八进制"

radiobutton_octal.addActionListener(this);

buttongroup_1.add(radiobutton_octal);

panel_radiobutton_1.add(radiobutton_octal);

radiobutton_hex=newJRadioButton("

十六进制"

radiobutton_hex.addActionListener(this);

buttongroup_1.add(radiobutton_hex);

panel_radiobutton_1.add(radiobutton_hex);

JPanelpanel_0=newJPanel(newGridLayout(1,2));

panel.add(panel_0);

JPanelpanel_radiobutton_2=newJPanel(newGridLayout(2,1));

panel_0.add(panel_radiobutton_2);

ButtonGroupbuttongroup_2=newButtonGroup();

radiobutton_angle=newJRadioButton("

角度"

radiobutton_angle.addActionListener(this);

buttongroup_2.add(radiobutton_angle);

panel_radiobutton_2.add(radiobutton_angle);

radiobutton_rad=newJRadioButton("

弧度"

radiobutton_rad.addActionListener(this);

buttongroup_2.add(radiobutton_rad);

panel_radiobutton_2.add(radiobutton_rad);

button_result=newJButton("

="

panel_0.add(button_result);

button_result.addActionListener(this);

panel_1=newJPanel(newGridLayout(1,4));

button_9=newJButton("

9"

button_8=newJButton("

8"

button_7=newJButton("

7"

button_clear=newJButton("

Clear"

this.add(panel_1);

panel_1.add(button_9);

panel_1.add(button_8);

panel_1.add(button_7);

panel_1.add(button_clear);

button_9.addActionListener(this);

button_8.addActionListener(this);

button_7.addActionListener(this);

button_clear.addActionListener(this);

panel_2=newJPanel(newGridLayout(1,4));

button_6=newJButton("

6"

button_5=newJButton("

5"

button_4=newJButton("

4"

button_plus=newJButton("

+"

this.add(panel_2);

panel_2.add(button_6);

panel_2.add(button_5);

panel_2.add(button_4);

panel_2.add(button_plus);

button_6.addActionListener(this);

button_5.addActionListener(this);

button_4.addActionListener(this);

button_plus.addActionListener(this);

panel_3=newJPanel(newGridLayout(1,4));

button_3=newJButton("

3"

button_2=newJButton("

2"

button_1=newJButton("

1"

button_minus=newJButton("

-"

this.add(panel_3);

panel_3.add(button_3);

panel_3.add(button_2);

panel_3.add(button_1);

panel_3.add(button_minus);

button_3.addActionListener(this);

button_2.addActionListener(this);

button_1.addActionListener(this);

button_minus.addActionListener(this);

panel_4=newJPanel(newGridLayout(1,4));

button_0=newJButton("

0"

button_point=newJButton("

."

button_power10=newJButton("

10^"

button_multiply=newJButton("

*"

this.add(panel_4);

panel_4.add(button_0);

panel_4.add(button_point);

panel_4.add(button_power10);

panel_4.add(button_multiply);

button_0.addActionListener(this);

button_point.addActionListener(this);

button_power10.addActionListener(this);

button_multiply.addActionListener(this);

panel_5=newJPanel(newGridLayout(1,4));

button_PI=newJButton("

π"

button_e=newJButton("

e"

button_power=newJButton("

^"

button_divide=newJButton("

/"

this.add(panel_5);

panel_5.add(button_PI);

panel_5.add(button_e);

panel_5.add(button_power);

panel_5.add(button_divide);

button_PI.addActionListener(this);

button_e.addActionListener(this);

button_power.addActionListener(this);

button_divide.addActionListener(this);

panel_6=newJPanel(newGridLayout(1,4));

button_sin=newJButton("

sin"

button_cos=newJButton("

cos"

button_tan=newJButton("

tan"

button_left_bracket=newJButton("

("

this.add(panel_6);

panel_6.add(button_sin);

panel_6.add(button_cos);

panel_6.add(button_tan);

panel_6.add(button_left_bracket);

button_sin.addActionListener(this);

button_cos.addActionListener(this);

button_tan.addActionListener(this);

button_left_bracket.addActionListener(this);

panel_7=newJPanel(newGridLayout(1,4));

button_asin=newJButton("

asin"

button_acos=newJButton("

acos"

button_atan=newJButton("

atan"

button_right_bracket=newJButton("

)"

this.add(panel_7);

panel_7.add(button_asin);

panel_7.add(button_acos);

panel_7.add(button_atan);

panel_7.add(button_right_bracket);

button_asin.addActionListener(this);

button_acos.addActionListener(this);

button_atan.addActionListener(this);

button_right_bracket.addActionListener(this);

panel_8=newJPanel(newGridLayout(1,4));

button_log10=newJButton("

lg"

button_log=newJButton("

ln"

button_sqrt=newJButton("

√"

button_factorial=newJButton("

!

this.add(panel_8);

panel_8.add(button_log10);

panel_8.add(button_log);

panel_8.add(button_sqrt);

panel_8.add(button_factorial);

button_log10.addActionListener(this);

button_log.addActionListener(this);

button_sqrt.addActionListener(this);

button_factorial.addActionListener(this);

panel_9=newJPanel(newGridLayout(1,4));

button_F=newJButton("

F"

button_E=newJButton("

E"

button_D=newJButton("

D"

button_negative=newJButton("

±

this.add(panel_9);

panel_9.add(button_F);

panel_9.add(button_E);

panel_9.add(button_D);

panel_9.add(button_negative);

button_F.addActionListener(this);

button_E.addActionListener(this);

button_D.addActionListener(this);

button_negative.addActionListener(this);

panel_10=newJPanel(newGridLayout(1,4));

button_C=newJButton("

C"

button_B=newJButton("

B"

button_A=newJButton("

A"

button_Backspace=newJButton("

←Delete"

this.add(panel_10);

panel_10.add(button_C);

panel_10.add(button_B);

panel_10.add(button_A);

panel_10.add(button_Backspace);

button_C.addActionListener(this);

button_B.addActionListener(this);

button_A.addActionListener(this);

button_Backspace.addActionListener(this);

button_F.setEnabled(false);

button_E.setEnabled(false);

button_D.setEnabled(false);

button_C.setEnabled(false);

button_B.setEnabled(false);

button_A.setEnabled(false);

this.setVisible(true);

}

publicvoidactionPerformed(ActionEvente)

if(e.getSource()==radiobutton_angle)

{

if(l==1)

{

str0=str0.substring(0,i-2);

text.setText(str0);

text.append("

=\n"

result=result/Math.PI*180.0;

str_0=Double.toString(result);

for(intj=0;

j<

length-str_0.length();

j++)

text.append("

"

text.append(str_0);

}

}

else

if(e.getSource()==radiobutton_rad)

if(l==1)

{

str0=str0.substring(0,i-2);

text.setText(str0);

result=result*Math.PI/180.0;

str_0=Double.toString(result);

for(intj=0;

text.append("

text.append(str_0);

}

}

else

if(e.getSource()==radiobutton_decimal)

if(m==0)

{

if(l==1)

{

if(digit==2)

{

str0=str0.substring(0,i-2);

text.setText(str0);

text.append("

str_0=Integer.valueOf(str_0,2).toString();

for(intj=0;

text.append("

text.append(str_0);

}

else

if(digit==8)

{

str0=str0.substring(0,i-2);

text.setText(str0);

str_0=Integer.valueOf(str_0,8).toString();

for(intj=0;

text.append("

text.append(str_0);

}

else

if(digit==16)

{

str0=str0.substring(0,i-2

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

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

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

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