ImageVerifierCode 换一换
格式:DOCX , 页数:19 ,大小:16.20KB ,
资源ID:12208963      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/12208963.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(计算器.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

计算器.docx

1、计算器import java.awt.BorderLayout;import javax.swing.JPanel;import javax.swing.JFrame;import javax.swing.JTextField;import java.awt.GridBagLayout;import javax.swing.JButton;import java.awt.GridBagConstraints;import java.awt.GridLayout;import java.awt.ComponentOrientation;public class calculator extend

2、s JFrame private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JTextField jTextField = null; private JPanel jPanel = null; private JButton jButton = null; private JButton jButton1 = null; private JButton jButton2 = null; private JButton jButton3 = null; private

3、 JButton jButton4 = null; private JButton jButton5 = null; private JButton jButton6 = null; private JButton jButton7 = null; private JButton jButton8 = null; private JButton jButton9 = null; private JButton jButton10 = null; private JButton jButton11 = null; private JButton jButton12 = null; private

4、 JButton jButton13 = null; private JButton jButton14 = null; private JButton jButton15 = null; private double result=0; private String lastCommand=; / jve:decl-index=0: private boolean start=true; private JPanel jPanel1 = null; private JButton jButton16 = null; /* * This is the default constructor *

5、/ public qwert() super(); initialize(); /* * This method initializes this * * return void */ private void initialize() this.setSize(300, 200); this.setContentPane(getJContentPane(); this.setTitle(计算器); /* * This method initializes jContentPane * * return javax.swing.JPanel */ private JPanel getJCont

6、entPane() if (jContentPane = null) jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout(); jContentPane.add(getJPanel1(), BorderLayout.EAST); jContentPane.add(getJTextField(), BorderLayout.NORTH); jContentPane.add(getJPanel(), BorderLayout.CENTER); return jContentPane; /* * This meth

7、od initializes jTextField * * return javax.swing.JTextField */ private JTextField getJTextField() if (jTextField = null) jTextField = new JTextField(); return jTextField; /* * This method initializes jPanel * * return javax.swing.JPanel */ private JPanel getJPanel() if (jPanel = null) GridLayout gri

8、dLayout = new GridLayout(4,4); jPanel = new JPanel(); jPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); jPanel.setLayout(gridLayout); jPanel.add(getJButton(), null); jPanel.add(getJButton8(), null); jPanel.add(getJButton12(), null); jPanel.add(getJButton15(), null); jPanel.add(getJ

9、Button14(), null); jPanel.add(getJButton13(), null); jPanel.add(getJButton11(), null); jPanel.add(getJButton10(), null); jPanel.add(getJButton7(), null); jPanel.add(getJButton6(), null); jPanel.add(getJButton1(), null); jPanel.add(getJButton2(), null); jPanel.add(getJButton3(), null); jPanel.add(get

10、JButton4(), null); jPanel.add(getJButton5(), null); jPanel.add(getJButton9(), null); return jPanel; /* * This method initializes jButton * * return javax.swing.JButton */ private JButton getJButton() if (jButton = null) jButton = new JButton(); jButton.setText(1); jButton.addActionListener(new java.

11、awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.getText()+input); ); return jButton; /* * This method initializes jButton1 * * return javax.swing.JButton

12、 */ private JButton getJButton1() if (jButton1 = null) jButton1 = new JButton(); jButton1.setText(9); jButton1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); if(start) jTextField.setText(); start=fals

13、e; jTextField.setText(jTextField.getText()+input); ); return jButton1; /* * This method initializes jButton2 * * return javax.swing.JButton */ private JButton getJButton2() if (jButton2 = null) jButton2 = new JButton(); jButton2.setText(*); jButton2.addActionListener(new java.awt.event.ActionListene

14、r() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); calculate(Double.parseDouble(jTextField.getText(); lastCommand=input; start=true; ); return jButton2; /* * This method initializes jButton3 * * return javax.swing.JButton */ private JButton getJButton3()

15、 if (jButton3 = null) jButton3 = new JButton(); jButton3.setText(0); jButton3.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.

16、getText()+input); ); return jButton3; /* * This method initializes jButton4 * * return javax.swing.JButton */ private JButton getJButton4() if (jButton4 = null) jButton4 = new JButton(); jButton4.setText(.); jButton4.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(j

17、ava.awt.event.ActionEvent e) String input=e.getActionCommand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.getText()+input); ); return jButton4; /* * This method initializes jButton5 * * return javax.swing.JButton */ private JButton getJButton5() if (jButton5 = null)

18、jButton5 = new JButton(); jButton5.setText(=); jButton5.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); calculate(Double.parseDouble(jTextField.getText(); lastCommand=input; start=true; ); return jButt

19、on5; /* * This method initializes jButton6 * * return javax.swing.JButton */ private JButton getJButton6() if (jButton6 = null) jButton6 = new JButton(); jButton6.setText(8); jButton6.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) Stri

20、ng input=e.getActionCommand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.getText()+input); ); return jButton6; /* * This method initializes jButton7 * * return javax.swing.JButton */ private JButton getJButton7() if (jButton7 = null) jButton7 = new JButton(); jButton

21、7.setText(7); jButton7.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.getText()+input); ); return jButton7; /* * This method

22、initializes jButton8 * * return javax.swing.JButton */ private JButton getJButton8() if (jButton8 = null) jButton8 = new JButton(); jButton8.setText(2); jButton8.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCo

23、mmand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.getText()+input); ); return jButton8; /* * This method initializes jButton9 * * return javax.swing.JButton */ private JButton getJButton9() if (jButton9 = null) jButton9 = new JButton(); jButton9.setText(/); jButton9

24、.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); calculate(Double.parseDouble(jTextField.getText(); lastCommand=input; start=true; ); return jButton9; /* * This method initializes jButton10 * * return

25、javax.swing.JButton */ private JButton getJButton10() if (jButton10 = null) jButton10 = new JButton(); jButton10.setText(-); jButton10.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); calculate(Double.p

26、arseDouble(jTextField.getText(); lastCommand=input; start=true; ); return jButton10; /* * This method initializes jButton11 * * return javax.swing.JButton */ private JButton getJButton11() if (jButton11 = null) jButton11 = new JButton(); jButton11.setText(6); jButton11.addActionListener(new java.awt

27、.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) String input=e.getActionCommand(); if(start) jTextField.setText(); start=false; jTextField.setText(jTextField.getText()+input); ); return jButton11; /* * This method initializes jButton12 * * return javax.swing.JButton */ private JButton getJButton12() if (jButton12 = null) jButton12 = new JButton(); jButton12.setText(3); jButton12.addActionListener(new java.awt.event.ActionListener() p

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

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