1.首先展示效果图(仅是单项运算),作为新手尽量降低了耦合,希望能得到大佬指点。
(1)设置按键(作为一个父类)
import java.awt.Button;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class keying implements Textbookandcount {
private Button t0 = new Button("0");
private Button t1 = new Button("1");
private Button t2 = new Button("2");
private Button t3 = new Button("3");
private Button t4 = new Button("4");
private Button t5 = new Button("5");
private Button t6 = new Button("6");
private Button t7 = new Button("7");
private Button t8 = new Button("8");
private Button t9 = new Button("9");
private Button t10 = new Button("+");
private Button t11 = new Button("-");
private Button t12 = new Button("*");
private Button t13 = new Button("/");
private Button t14 = new Button("计算");
private Button t15 = new Button("清零");
private Panel p1 = new Panel();
Button[] BU = {
t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11