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

📄 frame1.java~1~

📁 Java图形编程实现的一个计算器小程序! (绝对原创!!!)
💻 JAVA~1~
📖 第 1 页 / 共 3 页
字号:
package truly;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import javax.swing.border.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Frame1 extends JFrame {  JPanel contentPane;  JLabel jLabel1 = new JLabel();  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JLabel jLabel5 = new JLabel();  JLabel jLabel6 = new JLabel();  JPanel jPanel1 = new JPanel();  JPanel jPanel2 = new JPanel();  JPanel jPanel3 = new JPanel();  JTextField jTextField1 = new JTextField();  XYLayout xYLayout2 = new XYLayout();  XYLayout xYLayout3 = new XYLayout();  JButton jButton2 = new JButton();  JButton jButton1 = 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 jButton110 = new JButton();  JButton jButton111 = new JButton();  JButton jButton112 = new JButton();  TitledBorder titledBorder1;  JPanel jPanel4 = new JPanel();  JButton jButton20 = new JButton();  JButton jButton21 = new JButton();  JButton jButton22 = new JButton();  JButton jButton23 = new JButton();  XYLayout xYLayout4 = new XYLayout();  JButton jButton24 = new JButton();  JButton jButton25 = new JButton();  JButton jButton26 = new JButton();  JButton jButton27 = new JButton();  JButton jButton28 = new JButton();  JButton jButton29 = new JButton();  JButton jButton210 = new JButton();  JButton jButton211 = new JButton();  JButton jButton212 = new JButton();  JButton jButton213 = new JButton();  JButton jButton214 = new JButton();  JButton jButton215 = new JButton();  JButton jButton216 = new JButton();  JButton jButton217 = new JButton();  JButton jButton218 = new JButton();  JButton jButton219 = new JButton();  JLabel jLabel7 = new JLabel();    boolean isResult = false;    boolean isAdd = false;    boolean isMul = false;    boolean isSub = false;    boolean isDiv = false;    boolean isPowerOff = false;    boolean isInOff = false;    boolean counter = false;    boolean shift = false;    boolean isXY = false;    float firstNum = 0;    float endNum = 0;    float result = 0;  JTextField jTextField2 = new JTextField();  JLabel jLabel8 = new JLabel();  TitledBorder titledBorder2;  JLabel jLabel9 = new JLabel();  JLabel jLabel10 = new JLabel();  JLabel jLabel11 = new JLabel();  JLabel jLabel12 = new JLabel();  JLabel jLabel13 = new JLabel();  JLabel jLabel14 = new JLabel();  JLabel jLabel15 = new JLabel();  JLabel jLabel16 = new JLabel();  JLabel jLabel17 = new JLabel();  JLabel jLabel18 = new JLabel();  JLabel jLabel19 = new JLabel();  JLabel jLabel20 = new JLabel();  JLabel jLabel21 = new JLabel();  JLabel jLabel22 = new JLabel();  JLabel jLabel23 = new JLabel();  JLabel jLabel24 = new JLabel();  JLabel jLabel25 = new JLabel();  JLabel jLabel26 = new JLabel();  JLabel jLabel27 = new JLabel();  JLabel jLabel28 = new JLabel();  JLabel jLabel29 = new JLabel();  JLabel jLabel30 = new JLabel();  JLabel jLabel31 = new JLabel();  JLabel jLabel32 = new JLabel();  JLabel jLabel33 = new JLabel();  //Construct the frame  public Frame1() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));    contentPane = (JPanel) this.getContentPane();    titledBorder1 = new TitledBorder("");    titledBorder2 = new TitledBorder("");    jLabel1.setFont(new java.awt.Font("Dialog", 3, 22));    jLabel1.setForeground(Color.white);    jLabel1.setText("TRULY");    contentPane.setLayout(xYLayout1);    this.getContentPane().setBackground(SystemColor.textText);    this.setSize(new Dimension(301, 463));    this.setTitle("多功能计算器");    jLabel2.setForeground(UIManager.getColor("CheckBoxMenuItem.selectionForeground"));    jLabel2.setText("AUTO   POWER   OFF");    jLabel3.setFont(new java.awt.Font("Dialog", 0, 11));    jLabel3.setForeground(Color.white);    jLabel3.setText("@");    contentPane.setBackground(Color.lightGray);    contentPane.setForeground(Color.white);    contentPane.setBorder(BorderFactory.createRaisedBevelBorder());    jLabel4.setFont(new java.awt.Font("Dialog", 0, 11));    jLabel4.setForeground(Color.white);    jLabel4.setText("SC107A");    jLabel5.setForeground(Color.white);    jLabel5.setText("SCIENTIFIC");    jLabel6.setForeground(Color.white);    jLabel6.setText("FUNCTION");    jPanel1.setBackground(Color.darkGray);    jPanel1.setBorder(BorderFactory.createRaisedBevelBorder());    jPanel1.setLayout(xYLayout3);    jPanel2.setBackground(Color.darkGray);    jPanel2.setBorder(BorderFactory.createRaisedBevelBorder());    jPanel3.setBackground(Color.darkGray);    jPanel3.setBorder(BorderFactory.createLoweredBevelBorder());    jPanel3.setLayout(xYLayout2);    jTextField1.setBackground(Color.lightGray);    jTextField1.setFont(new java.awt.Font("SansSerif", 1, 16));    jTextField1.setEditable(false);    jButton2.setBackground(Color.red);    jButton2.setFont(new java.awt.Font("Dialog", 1, 10));    jButton2.setForeground(Color.white);    jButton2.setText("2nd F");    jButton2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton2_actionPerformed(e);      }    });    jButton1.setBackground(Color.red);    jButton1.setFont(new java.awt.Font("Dialog", 1, 10));    jButton1.setForeground(Color.white);    jButton1.setText("DRG");    jButton3.setBackground(Color.orange);    jButton3.setFont(new java.awt.Font("Dialog", 1, 10));    jButton3.setForeground(Color.white);    jButton3.setText("OFF");    jButton3.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton3_actionPerformed(e);      }    });    jButton4.setBackground(new Color(92, 210, 66));    jButton4.setFont(new java.awt.Font("Dialog", 1, 10));    jButton4.setForeground(Color.white);    jButton4.setText("ON/C");    jButton4.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton4_actionPerformed(e);      }    });    jButton5.setBackground(Color.darkGray);    jButton5.setForeground(Color.white);    jButton5.setBorder(BorderFactory.createRaisedBevelBorder());    jButton5.setText("hyp");    jButton6.setBackground(Color.darkGray);    jButton6.setForeground(Color.white);    jButton6.setBorder(BorderFactory.createRaisedBevelBorder());    jButton6.setText("sin");    jButton6.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton6_actionPerformed(e);      }    });    jButton7.setBackground(Color.darkGray);    jButton7.setForeground(Color.white);    jButton7.setBorder(BorderFactory.createRaisedBevelBorder());    jButton7.setText("cos");    jButton7.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton7_actionPerformed(e);      }    });    jButton8.setBackground(Color.darkGray);    jButton8.setForeground(Color.white);    jButton8.setBorder(BorderFactory.createRaisedBevelBorder());    jButton8.setText("tan");    jButton8.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton8_actionPerformed(e);      }    });    jButton9.setBackground(Color.darkGray);    jButton9.setForeground(Color.white);    jButton9.setBorder(BorderFactory.createRaisedBevelBorder());    jButton9.setText("F<-E");    jButton10.setBackground(Color.darkGray);    jButton10.setForeground(Color.white);    jButton10.setBorder(BorderFactory.createRaisedBevelBorder());    jButton10.setText("CE");    jButton10.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton10_actionPerformed(e);      }    });    jButton11.setBackground(Color.darkGray);    jButton11.setFont(new java.awt.Font("Dialog", 0, 10));    jButton11.setForeground(Color.white);    jButton11.setBorder(BorderFactory.createRaisedBevelBorder());    jButton11.setText("DEG");    jButton12.setBackground(Color.darkGray);    jButton12.setForeground(Color.white);    jButton12.setBorder(BorderFactory.createRaisedBevelBorder());    jButton12.setText("In");    jButton12.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton12_actionPerformed(e);      }    });    jButton13.setBackground(Color.darkGray);    jButton13.setForeground(Color.white);    jButton13.setBorder(BorderFactory.createRaisedBevelBorder());    jButton13.setText("log");    jButton13.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton13_actionPerformed(e);      }    });    jButton14.setBackground(Color.darkGray);    jButton14.setForeground(Color.white);    jButton14.setBorder(BorderFactory.createRaisedBevelBorder());    jButton14.setText("a");    jButton15.setBackground(Color.darkGray);    jButton15.setForeground(Color.white);    jButton15.setBorder(BorderFactory.createRaisedBevelBorder());    jButton15.setText("b");    jButton16.setBackground(Color.darkGray);    jButton16.setForeground(Color.white);    jButton16.setBorder(BorderFactory.createRaisedBevelBorder());    jButton16.setText("<-");    jButton16.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton16_actionPerformed(e);      }    });    jButton17.setBackground(Color.darkGray);    jButton17.setForeground(Color.white);    jButton17.setBorder(BorderFactory.createRaisedBevelBorder());    jButton17.setText("exp");    jButton17.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton17_actionPerformed(e);      }    });    jButton18.setBackground(Color.darkGray);    jButton18.setForeground(Color.white);    jButton18.setBorder(BorderFactory.createRaisedBevelBorder());    jButton18.setText("yx");    jButton18.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton18_actionPerformed(e);      }    });    jButton19.setBackground(Color.darkGray);    jButton19.setForeground(Color.white);    jButton19.setBorder(BorderFactory.createRaisedBevelBorder());    jButton19.setText("sqrt");    jButton19.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton19_actionPerformed(e);      }    });    jButton110.setBackground(Color.darkGray);    jButton110.setForeground(Color.white);    jButton110.setBorder(BorderFactory.createRaisedBevelBorder());    jButton110.setText("x2");

⌨️ 快捷键说明

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