==== 2018年4月19日 17:56:20 更新 ===
项目地址在:https://github.com/qiao1406/java_calcultor/tree/dev
这两个星期学习了swing模块的一些内容,学习了java的GUI编程,自己动手写了一个计算器
首先是整个计算器的图形框架类CalFrame类
package Calculator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class CalFrame extends JFrame {
//配色
private final static Color OP_COLOR = new Color(251, 150, 110);
private final static Color NUM_COLOR = new Color(36, 147, 190);
private final static Color EQUAL_COLOR = new Color(239, 187, 36);
private final static Color CLR_COLOR = new Color(50, 252, 75);
private final static Color DEL_COLOR = new Color(0, 152, 120);
private final static Font FONT1 = new Font("黑体", Font.BOLD, 20);
private final static Font FONT2 = new Font("微软雅黑", Font.PLAIN, 20);
private final static Font FONT3 = new Font("微软雅黑", Font.PLAIN, 15);
private JButton num0 = new JButton("0");
private JButton num1 = new JButton("1");
private JButton num2 = new JButton("2");
private JButton num3 = new JButton("3");
private JButton num4 = new JButton("4");
private JButton num5 = new JButton("5");
private JButton num6 = new JButton("6");
private JButton num7 = new JButton("7");
private JButton num8 = new JButton("8");
private JButton num9 = new JButton("9");
private JButton decimalPoint = new JButton(".");
private JButton addButton = new JButton("+");
private JButton minusButton = new JButton("-");
private JButton mulButton = new JButton("X");
private JButton divButton = new JButton("÷");
private JButton equalButton = new JButton("=");
private JButton leftBracket = new JButton("(");
private JButton rightBracket = new JButton(")");
private JButton clearButton = new JButton("Clear");
private JButton deleteButton = new JButton("Del");
private JLabel equationLabel = new JLabel("算式");
private JLabel resultLabel = new JLabel("结果");
private JTextArea equation = new JTextArea(2,30);
private JTextArea result = new JTextArea(1,30);
private JPanel jp1 = new JPanel();
private JPanel jp2 = new JPanel();
public CalFrame () {
equation.setEditable(false);
result.setEditable(false);
//颜色,字体设置
colorAndFontSettings();
//添加动作
actionSettings();
//设置各个组成部分的位置
positionSettings();
//其他设置
setLayout( new GridLayout(2,1));
add(jp1);
add(jp2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false