/*
* MainFrame.java
*
* Created on __DATE__, __TIME__
*/
package dc.demo;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*
* @author __USER__
*/
public class MainFrame extends javax.swing.JFrame {
private String num1 = "0";
private String inputTemp = "";
private String opFlag = "";
public MainFrame() {
initComponents();
usrInit();
}
private void usrInit() {
this.txtResult.setEditable(false);
// ActionListener numListener=new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// processNumber(e.getActionCommand());
// }
// };
//
// this.btnNum0.addActionListener(numListener);
// this.btnNum1.addActionListener(numListener);
// this.btnNum2.addActionListener(numListener);
// this.btnNum3.addActionListener(numListener);
// this.btnNum4.addActionListener(numListener);
// this.btnNum5.addActionListener(numListener);
// this.btnNum6.addActionListener(numListener);
// this.btnNum7.addActionListener(numListener);
// this.btnNum8.addActionListener(numListener);
// this.btnNum9.addActionListener(numListener);
this.setSize(400, 300);
}
/** 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() {
pnlBase = new javax.swing.JPanel();
btnBack = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
btnEnd = new javax.swing.JButton();
btnNum7 = new javax.swing.JButton();
btnNum8 = new javax.swing.JButton();
btnNum9 = new javax.swing.JButton();
btnNum5 = new javax.swing.JButton();
btnNum4 = new javax.swing.JButton();
btnNum1 = new javax.swing.JButton();
btnNum6 = new javax.swing.JButton();
btnNum2 = new javax.swing.JButton();
btnNum3 = new javax.swing.JButton();
btnDian = new javax.swing.JButton();
btnFlag = new javax.swing.JButton();
btnNum0 = new javax.swing.JButton();
btnAdd = new javax.swing.JButton();
btnSub = new javax.swing.JButton();
btnMul = new javax.swing.JButton();
btnDiv = new javax.swing.JButton();
btnEqual = new javax.swing.JButton();
txtResult = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
fileMenu = new javax.swing.JMenu();
openMenuItem = new javax.swing.JMenuItem();
saveMenuItem = new javax.swing.JMenuItem();
saveAsMenuItem = new javax.swing.JMenuItem();
exitMenuItem = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
btnBack.setText("BackSpace");
btnBack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackActionPerformed(evt);
}
});
btnClear.setText("\u6e05\u9664");
btnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
btnEnd.setText("\u5f52\u96f6");
btnEnd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEndActionPerformed(evt);
}
});
btnNum7.setText("7");
btnNum7.setActionCommand("7");
btnNum7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum7ActionPerformed(evt);
}
});
btnNum8.setText("8");
btnNum8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum8ActionPerformed(evt);
}
});
btnNum9.setText("9");
btnNum9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum9ActionPerformed(evt);
}
});
btnNum5.setText("5");
btnNum5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum5ActionPerformed(evt);
}
});
btnNum4.setText("4");
btnNum4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum4ActionPerformed(evt);
}
});
btnNum1.setText("1");
btnNum1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum1ActionPerformed(evt);
}
});
btnNum6.setText("6");
btnNum6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum6ActionPerformed(evt);
}
});
btnNum2.setText("2");
btnNum2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum2ActionPerformed(evt);
}
});
btnNum3.setText("3");
btnNum3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum3ActionPerformed(evt);
}
});
btnDian.setText(".");
btnDian.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDianActionPerformed(evt);
}
});
btnFlag.setText("+/-");
btnFlag.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnFlag.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFlagActionPerformed(evt);
}
});
btnNum0.setText("0");
btnNum0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNum0ActionPerformed(evt);
}
});
btnAdd.setText("+");
btnAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddActionPerformed(evt);
}
});
btnSub.setText("-");
btnSub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSubActionPerformed(evt);
}
});
btnMul.setText("*");
btnMul.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMulActionPerformed(evt);
}
});
btnDiv.setText("/");
btnDiv.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDivActionPerformed(evt);
}
});
btnEqual.setText("=");
btnEqual.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEqualActionPerformed(evt);
}
});
javax.swing.GroupLayout pnlBaseLayout = new javax.swing.GroupLayout(
pnlBase);
pnlBase.setLayout(pnlBaseLayout);
pnlBaseLayout
.setHorizontalGroup(pnlBaseLayout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
pnlBaseLayout
.createSequentialGroup()
.addGroup(
pnlBaseLayout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
pnlBaseLayout
.createSequentialGroup()
.addGap(
12,
12,
12)
.addComponent(
btnBack)