这段代码是什么意思?
毕业设计
1
public void actionPerformed(ActionEvent e) {
for(int i=0;i<=9;i++){
if (flag==true){
if (e.getSource() == btNum[i]){
g=g+Integer.toString(i);
jt1.setText(s.concat(g));
c=Float.parseFloat(jt1.getText());
}
}
else if(flag==false){
if (e.getSource() == btNum[i]){
m=m+Integer.toString(i);
jt1.setText(s.concat(m));
b=Float.parseFloat(jt1.getText());
}
}
}
for(int i=0;i<=3;i++){
if (e.getSource() == btOper[i]){
jt1.setText("");
y=i;
flag=false;
g="";
m="";
}
}
if (e.getSource() == btOper[4]){
jt1.setText("");
flag=false;
g="";
m="";
}
if(e.getSource() == btEqual){
switch(y){
case 0: num=c+b;break;
case 1: num=c-b;break;
case 2: num=c*b;break;
case 3: num=c/b;break;
case 4: num=c%b;break;
}
jt1.setText(num+"");
c=0;b=0;num=0;
flag=true;
}
}
public void click(){
for(int i=0;i<=9;i++){
btNum[i].addActionListener(this);
}
for(int i=0;i<=4;i++){
btOper[i].addActionListener(this);
}
btEqual.addActionListener(this);
}
public static void main(String[]args){
test03 c1=new test03("简易计算器");
c1.click();
}
}
发表回复