⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xxjisuanqi.java

📁 科学计算器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package xxjisuanqi;

import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.BorderFactory;
import java.awt.Font;

/**
 * <p>Title:XXjiquanqi </p>
 *
 * <p>Description: My first program</p>
 *
 * <p>Copyright: 9.9</p>
 *
 * <p>Company: Bamboo software</p>
 *
 * @author lishuangjiu
 * @version 9.9
 */
public class XXjisuanqi extends JFrame {
    String xianshi,save;
   double cun,buff,buff1;
   char oper;
   boolean xian,suan,deng,xin,hui,shan;
   boolean lian,jiu,shuang,lei,xi=true;
   char zhan[]=new char[30];

    JPanel contentPane;
    JMenuBar jMenuBar1 = new JMenuBar();
    JMenu jMenuFile = new JMenu();
    JMenuItem jMenuFileExit = new JMenuItem();
    JMenu jMenuHelp = new JMenu();
    JMenuItem jMenuHelpAbout = new JMenuItem();
    ImageIcon image1 = new ImageIcon(xxjisuanqi.XXjisuanqi.class.getResource(
            "openFile.png"));
    ImageIcon image2 = new ImageIcon(xxjisuanqi.XXjisuanqi.class.getResource(
            "closeFile.png"));
    ImageIcon image3 = new ImageIcon(xxjisuanqi.XXjisuanqi.class.getResource(
            "help.png"));
    JLabel statusBar = new JLabel();
    JTextField jTextField1 = new JTextField();
    JPanel jPanel1 = new JPanel();
    GridLayout gridLayout1 = new GridLayout();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    JButton jButton5 = new JButton();
    JButton jButton6 = new JButton();
    JButton jButton7 = new JButton();
    JButton jButton8 = new JButton();
    JButton jButton9 = new JButton();
    JButton jButton10 = new JButton();
    JButton jButton11 = new JButton();
    JButton jButton12 = new JButton();
    JButton jButton13 = new JButton();
    JButton jButton14 = new JButton();
    JButton jButton15 = new JButton();
    JButton jButton16 = new JButton();
    JButton jButton17 = new JButton();
    JButton jButton18 = new JButton();
    JButton jButton19 = new JButton();
    JButton jButton20 = new JButton();
    JPanel jPanel2 = new JPanel();
    GridLayout gridLayout2 = new GridLayout();
    JButton jButton21 = new JButton();
    JButton jButton22 = new JButton();
    JButton jButton23 = new JButton();
    JButton jButton24 = new JButton();
    JPanel jPanel3 = new JPanel();
    GridLayout gridLayout3 = new GridLayout();
    JButton jButton25 = new JButton();
    JButton jButton26 = new JButton();
    JButton jButton27 = new JButton();
    JTextArea jTextArea1 = new JTextArea();
    public XXjisuanqi() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(null);
        setSize(new Dimension(400, 300));
        setTitle("XXjisuanqi");
        statusBar.setText(" ");
        statusBar.setBounds(new Rectangle(0, 285, 400, 15));
        jMenuFile.setText("File");
        jMenuFileExit.setText("Exit");
        jMenuFileExit.addActionListener(new
                                        XXjisuanqi_jMenuFileExit_ActionAdapter(this));
        jMenuHelp.setText("Help");
        jMenuHelpAbout.setText("About");
        jMenuHelpAbout.addActionListener(new
                                         XXjisuanqi_jMenuHelpAbout_ActionAdapter(this));
        jTextField1.setBounds(new Rectangle(25, 1, 344, 30));
        jPanel1.setBounds(new Rectangle(110, 81, 273, 158));
        jPanel1.setLayout(gridLayout1);
        gridLayout1.setColumns(5);
        gridLayout1.setHgap(5);
        gridLayout1.setRows(4);
        gridLayout1.setVgap(5);
        jButton1.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton1.setForeground(Color.blue);
        jButton1.setText("7");
        jButton1.addActionListener(new XXjisuanqi_jButton1_actionAdapter(this));
        jButton2.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton2.setForeground(Color.blue);
        jButton2.setText("8");
        jButton2.addActionListener(new XXjisuanqi_jButton2_actionAdapter(this));
        jButton3.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton3.setForeground(Color.blue);
        jButton3.setText("9");
        jButton3.addActionListener(new XXjisuanqi_jButton3_actionAdapter(this));
        jButton4.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
        jButton4.setForeground(Color.red);
        jButton4.setText("/");
        jButton4.addActionListener(new XXjisuanqi_jButton4_actionAdapter(this));
        jButton5.setFont(new java.awt.Font("新宋体", Font.PLAIN, 8));
        jButton5.setForeground(Color.blue);
        jButton5.setText("sqrt");
        jButton5.addActionListener(new XXjisuanqi_jButton5_actionAdapter(this));
        jButton6.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton6.setForeground(Color.blue);
        jButton6.setText("4");
        jButton6.addActionListener(new XXjisuanqi_jButton6_actionAdapter(this));
        jButton7.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton7.setForeground(Color.blue);
        jButton7.setText("6");
        jButton7.addActionListener(new XXjisuanqi_jButton7_actionAdapter(this));
        jButton8.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton8.setForeground(Color.blue);
        jButton8.setText("1");
        jButton8.addActionListener(new XXjisuanqi_jButton8_actionAdapter(this));
        jButton9.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton9.setForeground(Color.blue);
        jButton9.setText("5");
        jButton9.addActionListener(new XXjisuanqi_jButton9_actionAdapter(this));
        jButton10.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton10.setForeground(Color.red);
        jButton10.setText("*");
        jButton10.addActionListener(new XXjisuanqi_jButton10_actionAdapter(this));
        jButton11.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton11.setForeground(Color.blue);
        jButton11.setText("3");
        jButton11.addActionListener(new XXjisuanqi_jButton11_actionAdapter(this));
        jButton12.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton12.setForeground(Color.blue);
        jButton12.setText("%");
        jButton12.addActionListener(new XXjisuanqi_jButton12_actionAdapter(this));
        jButton13.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton13.setForeground(Color.blue);
        jButton13.setText("2");
        jButton13.addActionListener(new XXjisuanqi_jButton13_actionAdapter(this));
        jButton14.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton14.setForeground(Color.red);
        jButton14.setText("-");
        jButton14.addActionListener(new XXjisuanqi_jButton14_actionAdapter(this));
        jButton15.setForeground(Color.blue);
        jButton15.setText("+/-");
        jButton15.addActionListener(new XXjisuanqi_jButton15_actionAdapter(this));
        jButton16.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
        jButton16.setForeground(Color.blue);
        jButton16.setText(".");
        jButton16.addActionListener(new XXjisuanqi_jButton16_actionAdapter(this));
        jButton17.setForeground(Color.blue);
        jButton17.setToolTipText("");
        jButton17.setText("1/x");
        jButton17.addActionListener(new XXjisuanqi_jButton17_actionAdapter(this));
        jButton18.setFont(new java.awt.Font("隶书", Font.BOLD, 15));
        jButton18.setForeground(Color.blue);
        jButton18.setText("0");
        jButton18.addActionListener(new XXjisuanqi_jButton18_actionAdapter(this));
        jButton19.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton19.setForeground(Color.red);
        jButton19.setText("+");
        jButton19.addActionListener(new XXjisuanqi_jButton19_actionAdapter(this));
        jButton20.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton20.setForeground(Color.red);
        jButton20.setText("=");
        jButton20.addActionListener(new XXjisuanqi_jButton20_actionAdapter(this));
        jPanel2.setBounds(new Rectangle(12, 81, 82, 156));
        jPanel2.setLayout(gridLayout2);
        gridLayout2.setColumns(1);
        gridLayout2.setHgap(6);
        gridLayout2.setRows(4);
        gridLayout2.setVgap(6);
        jButton21.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton21.setForeground(Color.red);
        jButton21.setText("MC");
        jButton21.addActionListener(new XXjisuanqi_jButton21_actionAdapter(this));
        jButton22.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton22.setForeground(Color.red);
        jButton22.setText("MR");
        jButton22.addActionListener(new XXjisuanqi_jButton22_actionAdapter(this));
        jButton23.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton23.setForeground(Color.red);
        jButton23.setText("MS");
        jButton23.addActionListener(new XXjisuanqi_jButton23_actionAdapter(this));
        jButton24.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton24.setForeground(Color.red);
        jButton24.setText("M+");
        jButton24.addActionListener(new XXjisuanqi_jButton24_actionAdapter(this));
        jPanel3.setBounds(new Rectangle(99, 38, 280, 36));
        jPanel3.setLayout(gridLayout3);
        gridLayout3.setColumns(3);
        gridLayout3.setHgap(8);
        gridLayout3.setVgap(8);
        jButton25.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
        jButton25.setForeground(Color.red);
        jButton25.setText("Backspace");
        jButton25.addActionListener(new XXjisuanqi_jButton25_actionAdapter(this));
        jButton26.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton26.setForeground(Color.red);
        jButton26.setText("CE");
        jButton26.addActionListener(new XXjisuanqi_jButton26_actionAdapter(this));
        jButton27.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jButton27.setForeground(Color.red);
        jButton27.setText("C");
        jButton27.addActionListener(new XXjisuanqi_jButton27_actionAdapter(this));
        jTextArea1.setBackground(SystemColor.control);
        jTextArea1.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jTextArea1.setBorder(BorderFactory.createLoweredBevelBorder());
        jTextArea1.setBounds(new Rectangle(17, 37, 57, 37));
        jMenuBar1.add(jMenuFile);
        jMenuFile.add(jMenuFileExit);
        jMenuBar1.add(jMenuHelp);
        jMenuHelp.add(jMenuHelpAbout);
        setJMenuBar(jMenuBar1);
        contentPane.add(statusBar, null);
        contentPane.add(jTextField1);
        contentPane.add(jPanel1);
        contentPane.add(jPanel2);
        contentPane.add(jPanel3);
        contentPane.add(jTextArea1);
        jPanel3.add(jButton25);
        jPanel3.add(jButton26);
        jPanel3.add(jButton27);
        jPanel2.add(jButton21);
        jPanel2.add(jButton22);
        jPanel2.add(jButton23);
        jPanel2.add(jButton24);
        jPanel1.add(jButton1);
        jPanel1.add(jButton2);
        jPanel1.add(jButton3);
        jPanel1.add(jButton4);
        jPanel1.add(jButton5);
        jPanel1.add(jButton6);
        jPanel1.add(jButton9);
        jPanel1.add(jButton7);
        jPanel1.add(jButton10);
        jPanel1.add(jButton12);
        jPanel1.add(jButton8);
        jPanel1.add(jButton13);
        jPanel1.add(jButton11);
        jPanel1.add(jButton14);
        jPanel1.add(jButton17);
        jPanel1.add(jButton18);
        jPanel1.add(jButton15);
        jPanel1.add(jButton16);
        jPanel1.add(jButton19);
        jPanel1.add(jButton20);
    }

    /**
     * File | Exit action performed.
     *
     * @param actionEvent ActionEvent
     */
    void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
        System.exit(0);
    }

    /**
     * Help | About action performed.
     *
     * @param actionEvent ActionEvent
     */
    void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
        XXjisuanqi_AboutBox dlg = new XXjisuanqi_AboutBox(this);
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                        (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();
        dlg.setVisible(true);
    }
    public void jButton27_actionPerformed(ActionEvent e) {
        xian=true;
       suan=false;
       xin=true;
       lian=false;
       jiu=false;
       deng=false;
       shuang=false;
       lei=false;
       hui=false;
       xi=true;
       oper='a';

      jTextField1.setText("0.");
        buff=0;
        buff1=0;

 }


    public void jButton1_actionPerformed(ActionEvent e) {
        if(xian==true){
                 jTextField1.setText("");
                }

               jTextField1.setText(jTextField1.getText()+"7");

              xin=false;
              xian=false;
              lian=true;
              suan=true;
             shan=false;
              jiu=false;
              shuang=false;
              lei=false;
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        if(xian==true||xin==true||jiu==true||shuang==true||lei==true){
              jTextField1.setText("");
             }


           jTextField1.setText(jTextField1.getText()+"8");

            xin=false;
              xian=false;
              lian=true;
              suan=true;
           shan=false;
              jiu=false;
              shuang=false;
              lei=false;
    }

    public void jButton3_actionPerformed(ActionEvent e) {
        if(xian==true||xin==true||jiu==true||shuang==true||lei==true){
               jTextField1.setText("");
              }
            jTextField1.setText(jTextField1.getText()+"9");

              xin=false;
              xian=false;
              lian=true;
             suan=true;
             shan=false;
            jiu=false;
            shuang=false;
            lei=false;
    }

    public void jButton6_actionPerformed(ActionEvent e) {
        if(xian==true||xin==true||jiu==true||shuang==true||lei==true){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -