cclt.setLayout(null);
final TextField text = new TextField();
text.setBounds(10, 30, 280, 35);
text.setText("0");
text.setEditable(false);
Font font = new Font("", 5, 25);
text.setFont(font);
cclt.add(text);
Panel panel = new Panel();
Font font_1 = new Font("", 5, 20);
panel.setFont(font_1);
panel.setBounds(5, 67, 290, 193);
panel.setBackground(Color.GREEN);
panel.setLayout(new GridLayout(5,4,5,5));
cclt.add(panel);
Button space = new Button();
panel.add(space);
Button Backspace = new Button("Backspace");
Font font_2 = new Font("", 0, 14);
Backspace.setFont(font_2);
panel.add(Backspace);
Button CE = new Button("CE");
panel.add(CE);
Button C = new Button("C");
panel.add(C);
Button seven = new Button("7");
panel.add(seven);
Button eight = new Button("8");
panel.add(eight);
Button nine = new Button("9");
panel.add(nine);
Button but = new Button("/");
panel.add(but);
Button four = new Button("4");
panel.add(four);
Button five = new Button("5");
panel.add(five);
Button six = new Button("6");
panel.add(six);
Button ride = new Button("*");
panel.add(ride);
Button one = new Button("1");
panel.add(one);
Button two = new Button("2");
panel.add(two);
Button three = new Button("3");
panel.add(three);
Button substract = new Button("-");
panel.add(substract);
Button zero = new Button("0");
panel.add(zero);
Button space_1 = new Button(" ");
panel.add(space_1);
Button equal = new Button("=");
panel.add(equal);
Button add = new Button("+");
panel.add(add);
CE.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
d1=0;
d2=0;
s1="0";
s2="0";
c1 ='0';
text.setText("0");
}
});
seven.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="7";
else {text.setText(s1+"7");
s1+="7";}
text.setText(s1);
}
});
eight.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="8";
else {text.setText(s1+"8");
s1+="8";}
text.setText(s1);
}
});
nine.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="9";
else {text.setText(s1+"9");
s1+="9";}
text.setText(s1);
}
});
four.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="4";
else {text.setText(s1+"4");
s1+="4";}
text.setText(s1);
}
});
five.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="5";
else {text.setText(s1+"5");
s1+="5";}
text.setText(s1);
}
});
six.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="6";
else {text.setText(s1+"6");
s1+="6";}
text.setText(s1);
}
});
one.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="1";
else {text.setText(s1+"1");
s1+="1";}
text.setText(s1);
}
});
two.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
if(s1.equals("0")) s1="2";
else {text.setText(s1+"2");
s1+="2";}
text.setText(s1);
}
推荐阅读
- 生存经营题材电脑游戏下载,生存经营玩法的策略游戏
- 关于网际飞车游戏手机安卓版的信息
- 玩游戏算休闲娱乐吗,打游戏是不是娱乐
- 电脑显示器hdmi怎么连接电脑,显示器hdmi接口怎么连接电脑主机
- php操作数据库常用命令 php中数据库怎么设计
- html页面无法返回代码,html页面无法返回代码怎么办
- 查看端口sqlserver端口号,sql server查看端口号
- 硬盘异常关机怎么修复,硬盘出现故障会怎么样
- 服务器java代码 java编写服务器端