我正在尝试创建一个作为测验的摇摆应用程序。我需要 jLabel 在单击按钮时进行更改,但是当我单击按钮时,应用程序会锁定。有人可以指出我正确的方向吗?
我的按钮点击代码如下:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String[] questions = {"test0","test1","test2","test3","test4","test5","test6"};
String[] answers = {"","","","","","",""};
int i = 0;
do {
jLabel2.setText(questions[i]);
index.setText(String.valueOf(i));
if (txtAnswer.getText().toLowerCase().equals(answers[i].toLowerCase())) {
i++;
jLabel2.setText(questions[i]);
}
else {
add(lblWrong);
}
}
while(i < 7);
}
我收到一条警告说 evt 参数尚未使用,这可能是个问题吗?
谢谢