📄 calend.java~11~
字号:
package calendar;
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JPanel;
import com.borland.jbcl.layout.XYConstraints;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.Color;
import com.borland.jbcl.layout.XYLayout;
import javax.swing.JTextField;
import javax.swing.JButton;
import com.borland.jbcl.layout.*;
import javax.swing.JTextArea;
public class Calend extends JPanel implements ActionListener {
double result = 0, data1 = 0, radixPointDepth = 1;
boolean radixPointIndicate = false, resultIndicate = false;
char prec = '+';
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JTextField jTextField1 = new JTextField();
JTextArea jTextArea1 = new JTextArea();
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
JButton jButton2 = 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 jButton20 = new JButton();
JButton jButton21 = new JButton();
JButton jButton22 = new JButton();
JButton jButton23 = new JButton();
JButton jButton24 = new JButton();
JButton jButton25 = new JButton();
JButton jButton26 = new JButton();
JButton jButton27 = new JButton();
/*
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b10.addActionListener(this);
b11.addActionListener(this);
b12.addActionListener(this);
b13.addActionListener(this);
b14.addActionListener(this);
b15.addActionListener(this);
b16.addActionListener(this);
b17.addActionListener(this);
*/
public Calend() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void actionPerformed(ActionEvent e) {
String s;
s = e.getActionCommand();
switch (s.charAt(0)) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (resultIndicate) {
result = 0;
data1 = 0;
prec = '+';
}
Integer Int1 = new Integer(s);
if (radixPointIndicate) {
radixPointDepth = radixPointDepth / 10;
data1 = data1 + (Int1.intValue()) * radixPointDepth;
} else {
data1 = data1 * 10 + (Int1.intValue());
}
Double displayNumber = new Double(data1);
jTextField1.setText(displayNumber.toString());
resultIndicate = false;
break;
case '+':
case '-':
case '*':
case '/':
case '=':
if (s.charAt(0) != '=' && resultIndicate) {
prec = s.charAt(0);
resultIndicate = false;
} else {
switch (prec) {
case '+':
result = result + data1;
break;
case '-':
result = result - data1;
break;
case '*':
result = result * data1;
break;
case '/':
result = result / data1;
break;
}
}
radixPointIndicate = false;
radixPointDepth = 1;
displayNumber = new Double(result);
jTextField1.setText(displayNumber.toString());
if (s.charAt(0) != '=') {
data1 = 0;
prec = s.charAt(0);
} else {
resultIndicate = true;
}
break;
case '.':
radixPointIndicate = true;
break;
}
if (s.equals("C")) {
result = 0;
data1 = 0;
radixPointDepth = 1;
jTextField1.setText("");
}
}
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
jPanel1.setLayout(xYLayout1);
jButton1.setText("Back");
jButton2.setText("CE");
jButton3.setText("C");
jButton4.setText("MC");
jButton5.setText("MR");
jButton6.setText("MS");
jButton7.setText("M+");
jButton8.setText("7");
jButton9.setText("4");
jButton10.setText("1");
jButton11.setText("0");
jButton12.setText("8");
jButton13.setText("5");
jButton14.setText("2");
jButton15.setText("+/-");
jButton16.setText("9");
jButton17.setText("6");
jButton18.setText("3");
jButton19.setText(".");
jButton20.setText("/");
jButton21.setText("*");
jButton22.setText("-");
jButton23.setText("+");
jButton24.setText("s");
jButton25.setText("%");
jButton26.setText("1/x");
jButton27.setText("=");
jButton8.addActionListener(this);
jButton9.addActionListener(this);
jButton10.addActionListener(this);
jButton11.addActionListener(this);
jButton12.addActionListener(this);
jButton13.addActionListener(this);
jButton14.addActionListener(this);
jButton16.addActionListener(this);
jButton17.addActionListener(this);
jButton23.addActionListener(this);
jButton22.addActionListener(this);
jButton21.addActionListener(this);
jButton20.addActionListener(this);
jButton19.addActionListener(this);
jButton3.addActionListener(this);
jTextArea1.setEditable(false);
jPanel1.add(jButton4, new XYConstraints(2, 33, 44, 28));
this.add(jTextField1, java.awt.BorderLayout.NORTH);
this.add(jPanel1, java.awt.BorderLayout.CENTER);
jPanel1.add(jButton5, new XYConstraints(2, 65, 44, 28));
jPanel1.add(jButton6, new XYConstraints(2, 97, 44, 28));
jPanel1.add(jButton7, new XYConstraints(2, 129, 44, 28));
jPanel1.add(jButton8, new XYConstraints(55, 33, 44, 28));
jPanel1.add(jButton9, new XYConstraints(55, 65, 44, 28));
jPanel1.add(jButton10, new XYConstraints(55, 97, 44, 28));
jPanel1.add(jButton11, new XYConstraints(55, 129, 44, 28));
jPanel1.add(jButton12, new XYConstraints(100, 33, 44, 28));
jPanel1.add(jButton13, new XYConstraints(100, 65, 44, 28));
jPanel1.add(jButton14, new XYConstraints(100, 97, 44, 28));
jPanel1.add(jButton15, new XYConstraints(100, 129, 44, 28));
jPanel1.add(jButton16, new XYConstraints(145, 33, 44, 28));
jPanel1.add(jButton18, new XYConstraints(145, 97, 44, 28));
jPanel1.add(jButton17, new XYConstraints(145, 65, 44, 28));
jPanel1.add(jButton19, new XYConstraints(145, 129, 44, 28));
jPanel1.add(jButton23, new XYConstraints(190, 129, 44, 28));
jPanel1.add(jButton20, new XYConstraints(190, 33, 44, 28));
jPanel1.add(jButton21, new XYConstraints(190, 65, 44, 28));
jPanel1.add(jButton22, new XYConstraints(190, 97, 44, 28));
jPanel1.add(jButton24, new XYConstraints(235, 33, 44, 28));
jPanel1.add(jButton25, new XYConstraints(235, 65, 44, 28));
jPanel1.add(jButton26, new XYConstraints(235, 97, 44, 28));
jPanel1.add(jButton27, new XYConstraints(235, 129, 44, 28));
jPanel1.add(jButton1, new XYConstraints(55, 1, 70, 28));
jPanel1.add(jButton2, new XYConstraints(132, 1, 70, 28));
jPanel1.add(jButton3, new XYConstraints(208, 1, 70, 28));
jPanel1.add(jTextArea1, new XYConstraints(3, 2, 42, 26));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -