欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年java计算器源代码2.docx

    • 资源ID:12791252       资源大小:57.60KB        全文页数:50页
    • 资源格式: DOCX        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年java计算器源代码2.docx

    精品学习资源java 运算器源代码 仿 win7import java.awt.* ;import javax.swing.* ;import java.awt.event.*;class Cal extends JFrame implements ActionListener,MouseListenerJMenuBar menubar ;JMenu menu_check,menu_edit,menu_help;JMenuItem menuitem_science,menuitem_check,menuitem_exit,menuitem_copy, menuitem_paste,menuitem1_copy,menuitem1_paste,menuitem_chelp,menuitem_about;JCheckBoxMenuItem menuitem_standard ;JTextField ta1;int x,result2 ;double op1,op2,opall ;private boolean end=false,flag=false,add=false,sub=false,cheng=false,chu=false,flagop2=false ;JButton b_mc,b_mr,b_ms,b_mjia,b_mjian,b_tui,b_ce,b_c,b_jj, b_dui,b_7,b_8,b_9,b_chu,b_baifenhao,b_4,b_5,b_6,b_cheng, b_daoshu,b_1,b_2,b_3,b_jian,b_0,b_dian,b_jia,b_dengyu;JPanel p_all,p_button1,p_button2,p_txt,p1,p2,p3,p4,p5;欢迎下载精品学习资源private String str,resultstr ;JPopupMenu popupmenu ; Container con=this.getContentPane ;Font font=new Font" 微软雅黑 ",Font.PLAIN,12;Color color=new Color120,220,120 ;CalString ssupers;setSize220,315;setResizablefalse;setVisibletrue ;Dimension scr=Toolkit.getDefaultToolkit.getScreenSize ;Dimension frm=this.getSize ;setLocationscr.width-frm.width/2,scr.height-frm.height/ 2;Toolkit tk=Toolkit.getDefaultToolkit ;/ 程序默认图标设置setIconImagetk.createImage"D:sd.jpg";setDefaultCloseOperationJFrame.EXIT_ON_CLOSE;/-制作框架结构 -/-菜单栏 -menubar=new JMenuBar ;menubar.setPreferredSizenew Dimensionfrm.width,19;欢迎下载精品学习资源menu_check=new JMenu" 查看 V" ;menu_check.setFontfont ;menu_check.setForegroundColor.black ;menuitem_standard=new JCheckBoxMenuItem"标准型 ",true ;menuitem_standard.setFontfont;menuitem_standard.setForegroundColor.black;menuitem_science=new JMenuItem"科学型 ";menuitem_science.setFontfont ;menuitem_science.setForegroundColor.black ;menuitem_check=new JMenuItem"查看分组 ";menuitem_check.setFontfont ;menuitem_check.setForegroundColor.black ;menuitem_exit=new JMenuItem"退出 ";menuitem_exit.setFontfont;menuitem_exit.setForegroundColor.black ;menuitem_exit.addActionListenerthis;menu_check.addmenuitem_standard ;menu_check.addmenuitem_science ;menu_check.addSeparator ;menu_check.addmenuitem_check ;menu_check.addSeparator ;menu_check.addmenuitem_exit ;menubar.addmenu_check ;欢迎下载精品学习资源menu_edit=new JMenu" 编辑 E";menu_edit.setFontfont ;menu_edit.setForegroundColor.black ;menu_edit.setMnemonicKeyEvent.VK_E ;menuitem_copy=new JMenuItem"复制 C ";menuitem_copy.setFontfont ;menuitem_copy.setForegroundColor.black ;menuitem_copy.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_C,InputEvent.CTRL_MASK;menuitem_copy.addActionListenerthis;menuitem_paste=new JMenuItem"粘贴 P ";menuitem_paste.setFontfont;menuitem_paste.setForegroundColor.black ;menuitem_paste.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_V,InputEvent.CTRL_MASK; menuitem_paste.addActionListenerthis;menu_edit.addmenuitem_copy;menu_edit.addmenuitem_paste;menubar.addmenu_edit ;menu_help=new JMenu" 帮忙 H";menu_help.setFontfont ;menu_help.setForegroundColor.black ;欢迎下载精品学习资源menuitem_chelp=new JMenuItem"查看帮忙 ";menuitem_chelp.setFontfont;menuitem_chelp.setForegroundColor.black ;menuitem_about=new JMenuItem"关于运算器 ";menuitem_about.setFontfont;menuitem_about.setForegroundColor.black;menuitem_about.addActionListenerthis;menu_help.addmenuitem_chelp;menu_help.addSeparator ;menu_help.addmenuitem_about;menubar.addmenu_help ;setJMenuBarmenubar ;/-文本框 -ta1=new JTextField"0" ;ta1.setFontnew Font" 微软雅黑 ",Font.PLAIN,13;ta1.setEditablefalse ;/ta1.setOpaquefalse ;ta1.setHorizontalAlignmentJTextField.RIGHT ;ta1.setPreferredSizenew Dimensionfrm.width-26,45;ta1.addMouseListenerthis ;欢迎下载精品学习资源p_all=new JPanel;p_all.setPreferredSizenew Dimensionfrm.width-6,250;/p_all.setBackgroundcolor ;p_all.setLayoutnew FlowLayoutFlowLayout.CENTER,0,3;p_txt=new JPanel ;p_txt.setPreferredSizenew Dimensionfrm.width-6,53;p_txt.setLayoutnew FlowLayoutFlowLayout.CENTER,0,7 ;p_txt.addta1 ;p_all.addp_txt ;con.addp_all,BorderLayout.CENTER;/-按钮区 -p_button1=new JPanel ;p_button1.setPreferredSizenew Dimensionfrm.width-25,131;p_button1.setLayoutnew FlowLayoutFlowLayout.LEFT,0,3 ;p_all.addp_button1 ;p1=new JPanel;p1.setPreferredSizenew Dimensionfrm.width-25,127;p1.setLayoutnew GridLayout4,5,5,6 ;欢迎下载精品学习资源b_mc=new JButton"MC" ;b_mc.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_mc.setMarginnew Insets0,0,0,0 ;b_mc.setForegroundColor.blue ;b_mc.addActionListenerthis ;b_mr=new JButton"MR" ;b_mr.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_mr.setMarginnew Insets0,0,0,0 ;b_mr.setForegroundColor.blue ;b_mr.addActionListenerthis ;b_ms=new JButton"MS" ;b_ms.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_ms.setMarginnew Insets0,0,0,0 ;b_ms.setForegroundColor.blue ;b_ms.addActionListenerthis ;b_mjia=new JButton"M+" ;b_mjia.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_mjia.setMarginnew Insets0,0,0,0 ;b_mjia.setForegroundColor.blue ;b_mjia.addActionListenerthis ;b_mjian=new JButton"M-" ;b_mjian.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_mjian.setMarginnew Insets0,0,0,0;b_mjian.setForegroundColor.blue ;b_mjian.addActionListenerthis ;欢迎下载精品学习资源b_tui=new JButton" ";b_tui.setFontnew Font" 微软雅黑 ",Font.BOLD,14;b_tui.setMarginnew Insets0,0,0,0 ;b_tui.addActionListenerthis ;b_tui.setForegroundColor.red ;b_ce=new JButton"CE" ;b_ce.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_ce.setMarginnew Insets0,0,0,0 ;b_ce.setForegroundColor.red ;b_ce.addActionListenerthis ;b_c=new JButton"C" ;b_c.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_c.setMarginnew Insets0,0,0,0 ;b_c.setForegroundColor.red ;b_c.addActionListenerthis ;b_jj=new JButton";± "b_jj.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_jj.setMarginnew Insets0,0,0,0 ;b_jj.setForegroundColor.red ;b_jj.addActionListenerthis ;b_dui=new JButton" ";b_dui.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_dui.setMarginnew Insets0,0,0,0 ;b_dui.setForegroundColor.red ;b_dui.addActionListenerthis ;欢迎下载精品学习资源b_7=new JButton"7" ;b_7.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_7.setMarginnew Insets0,0,0,0 ;b_7.setForegroundColor.blue ;b_7.setMnemonicKeyEvent.VK_7 ;b_7.addActionListenerthis ;b_8=new JButton"8" ;b_8.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_8.setMarginnew Insets0,0,0,0 ;b_8.setForegroundColor.blue ;b_8.setMnemonicKeyEvent.VK_8 ;b_8.addActionListenerthis ;b_9=new JButton"9" ;b_9.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_9.setMarginnew Insets0,0,0,0 ;b_9.setForegroundColor.blue ;b_9.setMnemonicKeyEvent.VK_9 ;b_9.addActionListenerthis ;b_chu=new JButton"/" ;b_chu.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_chu.setMarginnew Insets0,0,0,0 ;b_chu.setForegroundColor.red ;b_chu.addActionListenerthis ;b_baifenhao=new JButton"%" ;b_baifenhao.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;欢迎下载精品学习资源b_baifenhao.setMarginnew Insets0,0,0,0;b_baifenhao.setForegroundColor.blue ;b_baifenhao.addActionListenerthis ;b_4=new JButton"4" ;b_4.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_4.setMarginnew Insets0,0,0,0 ;b_4.setForegroundColor.blue ;b_4.setMnemonicKeyEvent.VK_4 ;b_4.addActionListenerthis ;b_5=new JButton"5" ;b_5.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_5.setMarginnew Insets0,0,0,0 ;b_5.setForegroundColor.blue ;b_5.setMnemonicKeyEvent.VK_5 ;b_5.addActionListenerthis ;b_6=new JButton"6" ;b_6.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_6.setMarginnew Insets0,0,0,0 ;b_6.setForegroundColor.blue ;b_6.setMnemonicKeyEvent.VK_6 ;b_6.addActionListenerthis ;b_cheng=new JButton"*" ;b_cheng.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_cheng.setMarginnew Insets0,0,0,0 ;b_cheng.setForegroundColor.red ;欢迎下载精品学习资源b_cheng.addActionListenerthis ;b_daoshu=new JButton"1 /x" ;b_daoshu.setFontnew Font" 微软雅黑 ",Font.PLAIN,11;b_daoshu.setMarginnew Insets0,0,0,0 ;b_daoshu.setForegroundColor.blue ;b_daoshu.addActionListenerthis ;b_1=new JButton"1" ;b_1.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_1.setMarginnew Insets0,0,0,0 ;b_1.setForegroundColor.blue ;b_1.setMnemonicKeyEvent.VK_1 ;b_1.addActionListenerthis ;b_2=new JButton"2" ;b_2.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_2.setMarginnew Insets0,0,0,0 ;b_2.setForegroundColor.blue ;b_2.setMnemonicKeyEvent.VK_2 ;b_2.addActionListenerthis ;b_3=new JButton"3" ;b_3.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_3.setMarginnew Insets0,0,0,0 ;b_3.setForegroundColor.blue ;b_3.setMnemonicKeyEvent.VK_3 ;b_3.addActionListenerthis ;b_jian=new JButton"-" ;欢迎下载精品学习资源b_jian.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_jian.setMarginnew Insets0,0,0,0 ;b_jian.setForegroundColor.red ;b_jian.addActionListenerthis ;b_0=new JButton"0" ;b_0.setFontnew Font" 微软雅黑 ",Font.PLAIN,14;b_0.setMarginnew Insets0,0,0,0 ;b_0.setPreferredSizenew Dimension75,27 ;b_0.setForegroundColor.blue ;b_0.setMnemonicKeyEvent.VK_0 ;b_0.addActionListenerthis ;JLabel L1=new JLabel;L1.setPreferredSizenew Dimension5,3 ;b_dian=new JButton"." ;b_dian.setFontnew Font" 微软雅黑 ",Font.BOLD,14;b_dian.setMarginnew Insets0,0,0,0 ;b_dian.setPreferredSizenew Dimension35,27 ;b_dian.setForegroundColor.blue ;b_dian.addActionListenerthis ;JLabel L2=new JLabel;L2.setPreferredSizenew Dimension5,3 ;b_jia=new JButton"+" ;b_jia.setFontnew Font" 微软雅黑 ",Font.BOLD,14;b_jia.setMarginnew Insets0,0,0,0 ;b_jia.setPreferredSizenew Dimension35,27 ;欢迎下载精品学习资源b_jia.setForegroundColor.red ;b_jia.addActionListenerthis ;b_dengyu=new JButton"=" ;b_dengyu.setFontnew Font" 微软雅黑 ",Font.BOLD,22;b_dengyu.setMarginnew Insets0,0,0,0 ;b_dengyu.setPreferredSizenew Dimension35,60 ;b_dengyu.setForegroundColor.blue ;b_dengyu.addActionListenerthis ;p1.addb_mc ;p1.addb_mr ;p1.addb_ms ;p1.addb_mjia ;p1.addb_mjian ;p1.addb_tui ;p1.addb_ce ;p1.addb_c ;p1.addb_jj ;p1.addb_dui ;p1.addb_7 ;p1.addb_8 ;p1.addb_9 ;p1.addb_chu ;p1.addb_baifenhao ;欢迎下载精品学习资源p1.addb_4 ;p1.addb_5 ;p1.addb_6 ;p1.addb_cheng ;p1.addb_daoshu ;p_button1.addp1 ;p_button2=new JPanel ;p_button2.setPreferredSizenew Dimensionfrm.width-24,65;p_button2.setLayoutnew FlowLayoutFlowLayout.LEFT,0,0 ;p_all.addp_button2 ;p2=new JPanel;p2.setPreferredSizenew Dimension156,65 ;p2.setLayoutnew FlowLayoutFlowLayout.LEFT,0,1;p3=new JPanel;p3.setPreferredSizenew Dimension39,62 ;p3.setLayoutnew FlowLayoutFlowLayout.LEFT,4,0;p_button2.addp2 ;p_button2.addp3 ;欢迎下载精品学习资源p4=new JPanel;p4.setPreferredSizenew Dimension156,27 ;p4.setLayoutnew GridLayout1,4,5,5 ;p5=new JPanel;p5.setPreferredSizenew Dimension156,39 ;p5.setLayoutnew FlowLayoutFlowLayout.LEFT,0,5;p2.addp4 ;p2.addp5 ;p4.addb_1 ;p4.addb_2 ;p4.addb_3 ;p4.addb_jian ;p5.addb_0 ;p5.addL1;p5.addb_dian ;p5.addL2;p5.addb_jia ;p3.addb_dengyu ;/-快捷菜单对象 -popupmenu=new JPopupMenu ; / 快捷菜单对象欢迎下载精品学习资源menuitem1_copy=new JMenuItem"复制 ";menuitem1_copy.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_C,InputEvent.CTRL_MASK;menuitem1_copy.addActionListenerthis ;/ 监视鼠标右击菜单”复制“popupmenu.addmenuitem1_copy;menuitem1_paste=new JMenuItem"粘贴 ";menuitem1_paste.setAcceleratorKeyStroke.getKeyStrokeKeyEvent.VK_V,InputEvent.CTRL_MASK;menuitem1_paste.addActionListenerthis;/ 监视鼠标右击菜单”粘贴“popupmenu.addmenuitem1_paste;ta1.addpopupmenu ;con.validate ;validate ;/-功能区 -public void actionPerformedActionEvent e ife.getSource=menuitem_aboutJOptionPane.showMessageDialognull," 这是一个仿照win7的运算器!欢迎改进,n创作欢迎下载精品学习资源者:钟作明 "," 仿 win7 运算器 ",JOptionPane.INFORMATION_MESSAGE;ife.getSource=menuitem1_copy ta1.selectAll ;ta1.copy ;else ife.getSource=menuitem1_paste ta1.setEditabletrue ;ta1.setText"" ;ta1.paste;ta1.setEditablefalse ;else ife.getSource=menuitem_copy ta1.selectAll ;ta1.copy ;else ife.getSource=menuitem_paste ta1.setEditabletrue ;ta1.setText"" ;ta1.paste;ta1.setEditablefalse ;欢迎下载精品学习资源else ife.getSource=menuitem_exit System.exit0;else ife.getSource=b_ce ta1.setEditabletrue ;ta1.setText"0" ;ta1.setEditablefalse ;else ife.getSource=b_c ta1.setEditabletrue ;ta1.setText"0" ;ta1.setEditablefalse ;else ife.getSource=b_tuiString str=ta1.getText ;StringBuffer s=new StringBufferstr ;int L=s.length ;try ifL.=1s=s.deleteCharAtL-1;elses=new StringBuffer"0" ;欢迎下载精品学习资源catchException e1ta1.setTextString.valueOfs;/-数字键 -ife.getSource=b_1addString1 ;else ife.getSource=b_2addString2 ;else ife.getSource=b_3addString3 ;else ife.getSource=b_4addString4 ;else ife.getSource=b_5欢迎下载精品学习资源addString5 ;else ife.getSource=b_6addString6 ;else ife.getSource=b_7addString7 ;else ife.getSource=b_8addString8 ;else ife.getSource=b_9addString9 ;else ife.getSource=b_0addString0 ;else ife.getSource=b_dianStringBuffer s1=new StringBufferta1.getText ;StringBuffer dian=new StringBuffer".";欢迎下载精品学习资源ifString.valueOfs1.indexOf"."=-1 s1.appenddian ;ta1.setTextString.valueOfs1;else ife.getSource=b_jjString txt=ta1.getText ;int

    注意事项

    本文(2022年java计算器源代码2.docx)为本站会员(Che****ry)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开