那个JAVA大神帮我看看这个地方怎么改,谢谢!

2024-11-03 04:20:23
推荐回答(2个)
回答1:

public void actionPerformed(ActionEvent e) {
int a = s;// =(int)(Math.random()*20);
int b = Integer.valueOf(jt1.getText());
long start =0;
if (e.getSource() == jb3) {
start= System.currentTimeMillis();//将他设置成全局的变量
}
if (e.getSource() == jb1) {
if (b > a) {
jt2.setText("你猜大了!");
}
if (b < a) {
jt2.setText("你猜小了!");
}
if (b == a) {
jt2.setText("你猜对了");
long x = System.currentTimeMillis(); // jt3.setText((System.currentTimeMillis()
// - start) + "ms");
jt3.setText((x - start) + "ms");
}
}
}

回答2:

改成start