/*
* Calculate.java
*
* Created on __DATE__, __TIME__
*/
package com.calculate;
/**
*
* @author __USER__
*/
public class Calculate extends javax.swing.JFrame {
private String str1;
private String sign;
/** Creates new form Calculate */
public Calculate() {
initComponents();
}
public void showJTextField(String str) {
if (!str.contains("+") && !str.contains("-") && !str.contains("*")
&& !str.contains("/")) {
String temp = this.jTextField1.getText();
if (temp.equals("0")) {
temp = "";
}
this.jTextField1.setText(temp + str);
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
jPanel1 = new javax.swing.JPanel();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton17 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jButton13 = new javax.swing.JButton();
jButton14 = new javax.swing.JButton();
jButton16 = new javax.swing.JButton();
jButton15 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
setTitle("\u8ba1\u7b97\u5668");
setDefaultCloseOperation(3);
setLocationByPlatform(true);
jTextField1.setText("0");
jButton4.setText("4");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setText("5");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setText("6");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton1.setText("1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("3");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton10.setText("0");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jButton11.setText(".");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
jButton12.setText("=");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jButton8.setText("8");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton9.setText("9");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jButton7.setText("7");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton17.setText("Clear");
jButton17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton17ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout
.setHorizontalGroup(jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
jPanel1Layout
.createSequentialGroup()
.addContainerGap()
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
jPanel1Layout
.createSequentialGroup()
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
jButton7)
.add(
jButton4)
.add(
jButton10)
.add(
jButton1))
.add(
18,
18,
18)
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
jButton11)
.add(
jButton2)
.add(
jButton5)
.add(
jButton8))
.add(
18,
18,
18)
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
jButton6)
.add(
jButton9)
.add(
jButton3)
.add(
jButton12)))
.add(jButton17))
.addContainerGap(27, Short.MAX_VALUE)));
jPanel1Layout
.setVerticalGroup(jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.LEADING)
.add(
org.jdesktop.layout.GroupLayout.TRAILING,
jPanel1Layout
.createSequentialGroup()
.addContainerGap()
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton7).add(
jButton8).add(
jButton9))
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton4).add(
jButton5).add(
jButton6))
.addPreferredGap(
org.jdesktop.layout.LayoutStyle.RELATED)
.add(
jPanel1Layout
.createParallelGroup(
org.jdesktop.layout