SWT计算器代码求解释,求大神
网上粘贴一下部分代码,求解释public class Calculator {
Display display;
Shell shell;
String num = "0";
double result = 0, temp = 0;
int op = 0, pan = 1, dotpan = 0;
中间省略界面的设置
b1.addSelectionListener(new SelectionAdapter() { //按钮1的事件
@Override
public void widgetSelected(SelectionEvent e) {
if (pan == 0) {
num = "";//空的
text1.setText(num + 1);
pan = 1;
} else {
if (Double.parseDouble(text1.getText()) == 0 && dotpan != 1) {
text1.setText(num = "");
text1.setText(text1.getText() + 1);
} else
text1.setText(text1.getText() + 1);
}
num = text1.getText();
}
});
badd.addSelectionListener(new SelectionAdapter() { //按钮加号的事件
@Override
public void widgetSelected(SelectionEvent e) {
if (pan == 1 && result == 0) {
result = Double.parseDouble(num);
op = 1;
dotpan = 0;
pan = 0;
} else if (result != 0 && pan == 1) {
temp = Double.parseDouble(num);
result = result + temp;
text1.setText(num = String.valueOf(result));
temp = 0;
pan = 0;
} else if (pan == 0) {
result = Double.parseDouble(num);
temp = 0;
dotpan = 0;
op = 1;
}
}
});
主要解释一下开头定义的几个变量到底是什么意思