📄 jsq.java~14~
字号:
package jsq;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class jsq
extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JTextField Text = new JTextField();
JButton button_new = new JButton();
JButton button_cancel = new JButton();
JButton operatorButton1 = new JButton();
JButton numberButton_1 = new JButton();
JButton numberButton_2 = new JButton();
JButton numberButton_3 = new JButton();
JButton numberButton_4 = new JButton();
JButton numberButton_5 = new JButton();
JButton numberButton_6 = new JButton();
JButton numberButton_7 = new JButton();
JButton numberButton_8 = new JButton();
JButton numberButton_9 = new JButton();
JButton numberButton_10 = new JButton();
JButton numberButton_0 = new JButton();
JButton numberButton_11 = new JButton();
JButton operatorButton2 = new JButton();
JButton operatorButton3 = new JButton();
JButton operatorButton4 = new JButton();
JButton operatorButton5 = new JButton();
boolean end=true,first=true; //end判断是否结束,first判断是否按了操作键
int sign=0; //sing 表示操作符 ‘01234’=‘=+-*/’
double num1,num2,num3;
public jsq() {
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(xYLayout1);
setSize(new Dimension(400, 330));
setTitle("Frame Title");
contentPane.setToolTipText("");
Text.setEditable(false);
Text.setText("0");
button_new.setFont(new java.awt.Font("Dialog", Font.BOLD, 18));
button_new.setText("清零");
button_cancel.setFont(new java.awt.Font("Dialog", Font.BOLD, 18));
button_cancel.setText("重置");
operatorButton1.setFont(new java.awt.Font("Dialog", Font.BOLD, 20));
operatorButton1.setText("=");
numberButton_1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_1.setText("1");
numberButton_1.addActionListener(new jsq_numberButton_1_actionAdapter(this));
numberButton_2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_2.setText("2");
numberButton_2.addActionListener(new jsq_numberButton_2_actionAdapter(this));
numberButton_3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_3.setText("3");
numberButton_3.addActionListener(new jsq_numberButton_3_actionAdapter(this));
numberButton_4.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_4.setText("4");
numberButton_4.addActionListener(new jsq_numberButton_4_actionAdapter(this));
numberButton_5.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_5.setText("5");
numberButton_5.addActionListener(new jsq_numberButton_5_actionAdapter(this));
numberButton_6.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_6.setText("6");
numberButton_6.addActionListener(new jsq_numberButton_6_actionAdapter(this));
numberButton_7.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_7.setText("7");
numberButton_7.addActionListener(new jsq_numberButton_7_actionAdapter(this));
numberButton_8.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_8.setText("8");
numberButton_8.addActionListener(new jsq_numberButton_8_actionAdapter(this));
numberButton_9.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_9.setText("9");
numberButton_9.addActionListener(new jsq_numberButton_9_actionAdapter(this));
numberButton_10.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_10.setText("-");
numberButton_0.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_0.setText("0");
numberButton_0.addActionListener(new jsq_numberButton_0_actionAdapter(this));
numberButton_11.setFont(new java.awt.Font("Dialog", Font.PLAIN, 15));
numberButton_11.setText(".");
operatorButton2.setFont(new java.awt.Font("Dialog", Font.BOLD, 15));
operatorButton2.setText("/");
operatorButton3.setFont(new java.awt.Font("Dialog", Font.BOLD, 15));
operatorButton3.setText("*");
operatorButton4.setFont(new java.awt.Font("Dialog", Font.BOLD, 15));
operatorButton4.setText("-");
operatorButton5.setFont(new java.awt.Font("Dialog", Font.BOLD, 15));
operatorButton5.setText("+");
contentPane.add(Text, new XYConstraints(20, 21, 347, 39));
contentPane.add(button_cancel, new XYConstraints(145, 75, 95, 31));
contentPane.add(button_new, new XYConstraints(21, 75, 95, 31));
contentPane.add(operatorButton1, new XYConstraints(273, 76, 95, 31));
contentPane.add(operatorButton2, new XYConstraints(302, 126, 66, -1));
contentPane.add(operatorButton3, new XYConstraints(302, 168, 66, -1));
contentPane.add(numberButton_3, new XYConstraints(208, 126, 66, -1));
contentPane.add(numberButton_1, new XYConstraints(21, 126, 66, -1));
contentPane.add(numberButton_2, new XYConstraints(113, 126, 66, -1));
contentPane.add(numberButton_5, new XYConstraints(113, 168, 66, -1));
contentPane.add(numberButton_4, new XYConstraints(21, 168, 66, -1));
contentPane.add(numberButton_6, new XYConstraints(208, 168, 66, -1));
contentPane.add(operatorButton4, new XYConstraints(302, 215, 66, -1));
contentPane.add(numberButton_9, new XYConstraints(208, 215, 66, -1));
contentPane.add(numberButton_8, new XYConstraints(113, 215, 66, -1));
contentPane.add(numberButton_7, new XYConstraints(21, 215, 66, -1));
contentPane.add(numberButton_10, new XYConstraints(21, 263, 66, -1));
contentPane.add(numberButton_0, new XYConstraints(113, 263, 66, -1));
contentPane.add(numberButton_11, new XYConstraints(208, 263, 66, -1));
contentPane.add(operatorButton5, new XYConstraints(302, 263, 66, -1));
}
void number(String s){
if(end){
Text.setText(s);
end=false;
}
else if(Text.getText().equals("0")){
Text.setText(s);
}
else{
String str=Text.getText()+s;
Text.setText(str);
}
}
public void numberButton_1_actionPerformed(ActionEvent e) {
number("1");
}
public void numberButton_2_actionPerformed(ActionEvent e) {
number("2");
}
public void numberButton_3_actionPerformed(ActionEvent e) {
number("3");
}
public void numberButton_4_actionPerformed(ActionEvent e) {
number("4");
}
public void numberButton_5_actionPerformed(ActionEvent e) {
number("5");
}
public void numberButton_6_actionPerformed(ActionEvent e) {
number("6");
}
public void numberButton_7_actionPerformed(ActionEvent e) {
number("7");
}
public void numberButton_8_actionPerformed(ActionEvent e) {
number("8");
}
public void numberButton_9_actionPerformed(ActionEvent e) {
number("9");
}
public void numberButton_0_actionPerformed(ActionEvent e) {
number("0");
}
}
class jsq_numberButton_8_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_8_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_8_actionPerformed(e);
}
}
class jsq_numberButton_5_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_5_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_5_actionPerformed(e);
}
}
class jsq_numberButton_4_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_4_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_4_actionPerformed(e);
}
}
class jsq_numberButton_9_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_9_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_9_actionPerformed(e);
}
}
class jsq_numberButton_0_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_0_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_0_actionPerformed(e);
}
}
class jsq_numberButton_6_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_6_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_6_actionPerformed(e);
}
}
class jsq_numberButton_7_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_7_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_7_actionPerformed(e);
}
}
class jsq_numberButton_2_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_2_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_2_actionPerformed(e);
}
}
class jsq_numberButton_3_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_3_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_3_actionPerformed(e);
}
}
class jsq_numberButton_1_actionAdapter
implements ActionListener {
private jsq adaptee;
jsq_numberButton_1_actionAdapter(jsq adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.numberButton_1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -