📄 sdf.java
字号:
/*
* SDF.java
*
* Created on 2006年12月25日, 下午7:16
*/
package javaapplication16;
import javax.swing.JOptionPane;
/**
*
* @author hero
*/
public class SDF extends javax.swing.JFrame {
/** Creates new form SDF */
public SDF() {
initComponents();
setLocation(300,200);
pack();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
jButton12 = new javax.swing.JButton();
jButton28 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton35 = new javax.swing.JButton();
jButton16 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton29 = new javax.swing.JButton();
jButton34 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton14 = new javax.swing.JButton();
jButton30 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
display = new javax.swing.JTextField();
jButton12.setText("STO");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("\u8ba1\u7b97\u5668");
setBackground(new java.awt.Color(102, 255, 255));
jButton28.setBackground(new java.awt.Color(225, 232, 238));
jButton28.setForeground(new java.awt.Color(64, 136, 66));
jButton28.setText("7");
jButton28.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton28ActionPerformed(evt);
}
});
jButton7.setBackground(new java.awt.Color(225, 232, 238));
jButton7.setForeground(new java.awt.Color(64, 136, 66));
jButton7.setText("8");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton6.setBackground(new java.awt.Color(225, 232, 238));
jButton6.setForeground(new java.awt.Color(64, 136, 66));
jButton6.setText("9");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton13.setBackground(new java.awt.Color(225, 232, 238));
jButton13.setForeground(new java.awt.Color(64, 136, 66));
jButton13.setText("AC");
jButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});
jButton11.setBackground(new java.awt.Color(225, 232, 238));
jButton11.setForeground(new java.awt.Color(64, 136, 66));
jButton11.setText("RCL");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
jButton4.setBackground(new java.awt.Color(225, 232, 238));
jButton4.setForeground(new java.awt.Color(64, 136, 66));
jButton4.setText("6");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton2.setBackground(new java.awt.Color(225, 232, 238));
jButton2.setForeground(new java.awt.Color(64, 136, 66));
jButton2.setText("4");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton5.setBackground(new java.awt.Color(225, 232, 238));
jButton5.setForeground(new java.awt.Color(64, 136, 66));
jButton5.setText("5");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton35.setBackground(new java.awt.Color(225, 232, 238));
jButton35.setForeground(new java.awt.Color(64, 136, 66));
jButton35.setText("*");
jButton35.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton35ActionPerformed(evt);
}
});
jButton16.setBackground(new java.awt.Color(225, 232, 238));
jButton16.setForeground(new java.awt.Color(64, 136, 66));
jButton16.setText("-");
jButton16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton16ActionPerformed(evt);
}
});
jButton9.setBackground(new java.awt.Color(225, 232, 238));
jButton9.setForeground(new java.awt.Color(64, 136, 66));
jButton9.setText("1");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jButton3.setBackground(new java.awt.Color(225, 232, 238));
jButton3.setForeground(new java.awt.Color(64, 136, 66));
jButton3.setText("2");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton29.setBackground(new java.awt.Color(225, 232, 238));
jButton29.setForeground(new java.awt.Color(64, 136, 66));
jButton29.setText("3");
jButton29.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton29ActionPerformed(evt);
}
});
jButton34.setBackground(new java.awt.Color(225, 232, 238));
jButton34.setForeground(new java.awt.Color(64, 136, 66));
jButton34.setText("=");
jButton34.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton34ActionPerformed(evt);
}
});
jButton8.setBackground(new java.awt.Color(225, 232, 238));
jButton8.setForeground(new java.awt.Color(64, 136, 66));
jButton8.setText("0");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton1.setBackground(new java.awt.Color(225, 232, 238));
jButton1.setFont(new java.awt.Font("Arial", 1, 14));
jButton1.setForeground(new java.awt.Color(64, 136, 66));
jButton1.setText(".");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton14.setBackground(new java.awt.Color(225, 232, 238));
jButton14.setForeground(new java.awt.Color(64, 136, 66));
jButton14.setText("C");
jButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});
jButton30.setBackground(new java.awt.Color(225, 232, 238));
jButton30.setForeground(new java.awt.Color(64, 136, 66));
jButton30.setText("/");
jButton30.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton30ActionPerformed(evt);
}
});
jButton10.setBackground(new java.awt.Color(225, 232, 238));
jButton10.setFont(new java.awt.Font("宋体", 0, 14));
jButton10.setForeground(new java.awt.Color(64, 136, 66));
jButton10.setText("+");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
display.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
display.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
displayActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(display, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(jButton13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(12, 12, 12)
.add(jButton11))
.add(layout.createSequentialGroup()
.add(jButton28)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton7)
.add(21, 21, 21)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jButton4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton16, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(jButton29)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton35))
.add(layout.createSequentialGroup()
.add(jButton34)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jButton30))
.add(layout.createSequentialGroup()
.add(jButton6)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jButton10, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jButton14, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.add(layout.createSequentialGroup()
.add(jButton2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton5))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(jButton8)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(jButton9)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton3))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(35, 35, 35)
.add(display, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton13)
.add(jButton11)
.add(jButton14))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton28)
.add(jButton7)
.add(jButton6)
.add(jButton10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton2)
.add(jButton5)
.add(jButton4)
.add(jButton16))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton9)
.add(jButton3)
.add(jButton29)
.add(jButton35))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton8)
.add(jButton34)
.add(jButton30))
.add(jButton1))
.addContainerGap(26, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void displayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayActionPerformed
// TODO 将在此处添加您的处理代码:
}//GEN-LAST:event_displayActionPerformed
private void jButton34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton34ActionPerformed
if (opera==1)
{
i = new Double (display.getText());
display.setText("");
result = result + i.doubleValue();
display.setText(""+ result);
}
else if (opera==2)
{
i = new Double (display.getText());
display.setText("");
result = result - i.doubleValue();
display.setText(""+ result);
}
else if (opera==3)
{
i = new Double (display.getText());
display.setText("");
result = result * i.doubleValue();
display.setText(""+ result);
}
else if (opera==4)
{
i = new Double (display.getText());
display.setText("");
result = result / i.doubleValue();
display.setText(""+ result);
}
counter = 0;
result = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -