2022年java计算器源代码2.docx
《2022年java计算器源代码2.docx》由会员分享,可在线阅读,更多相关《2022年java计算器源代码2.docx(50页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精品学习资源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,menuit
2、em1_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_d
3、ui,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;C
4、olor 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 ;/ 程序默认图标设置setIconImag
5、etk.createImageD: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标准型 ,
6、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_e
7、xit=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 ;men
8、ubar.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.getKeyStroke
9、KeyEvent.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;men
10、u_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关于
11、运算器 ;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 JTextField0 ;ta1.setFontnew Font 微软雅黑 ,Font.PLAIN,13;t
12、a1.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 FlowLayoutFlowL
13、ayout.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.setLa
14、youtnew 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 JButtonMC ;b_mc.setFontnew Font 微软雅黑 ,Font.PLAIN,11;b_mc.setMarginnew Insets0,0,0,0 ;b_mc.setForegroundColor.blue ;b_mc.addA
15、ctionListenerthis ;b_mr=new JButtonMR ;b_mr.setFontnew Font 微软雅黑 ,Font.PLAIN,11;b_mr.setMarginnew Insets0,0,0,0 ;b_mr.setForegroundColor.blue ;b_mr.addActionListenerthis ;b_ms=new JButtonMS ;b_ms.setFontnew Font 微软雅黑 ,Font.PLAIN,11;b_ms.setMarginnew Insets0,0,0,0 ;b_ms.setForegroundColor.blue ;b_ms.
16、addActionListenerthis ;b_mjia=new JButtonM+ ;b_mjia.setFontnew Font 微软雅黑 ,Font.PLAIN,11;b_mjia.setMarginnew Insets0,0,0,0 ;b_mjia.setForegroundColor.blue ;b_mjia.addActionListenerthis ;b_mjian=new JButtonM- ;b_mjian.setFontnew Font 微软雅黑 ,Font.PLAIN,11;b_mjian.setMarginnew Insets0,0,0,0;b_mjian.setFo
17、regroundColor.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 JButtonCE ;b_ce.setFontnew Font 微软雅黑 ,Font.PLAIN,11;b_ce.setMarginnew Insets0
18、,0,0,0 ;b_ce.setForegroundColor.red ;b_ce.addActionListenerthis ;b_c=new JButtonC ;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
19、 ;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 JButton7 ;b_7.setFontnew Font 微软雅黑 ,Font.PLAIN,14;b_7.setMarginnew In
20、sets0,0,0,0 ;b_7.setForegroundColor.blue ;b_7.setMnemonicKeyEvent.VK_7 ;b_7.addActionListenerthis ;b_8=new JButton8 ;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 JButton9 ;b_9.set
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022 java 计算器 源代码
限制150内