给我一个问题
我有一张关于罪的照片,因为。。 文本区域1会告诉某人:“点击图片中的SIN” 如果用户这样做,文本区域2告诉他:“这是正确的”
之后,文本区域1。附加“点击图片中的COS” -但该程序仍在等待点击“犯罪”:( 你能帮帮我,给我一点建议吗
这里有一些代码:
private class KlikaniMysi implements MouseListener {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX() + " " + e.getY());
//for finding coordinates (by console)
//textArea2 = "try" at start !!
//textArea1 = "Find SIN" at start !!!!!!!!
if(textArea2.equals("try")){
if( (((e.getX()) > 420)&&((e.getX()) < 580)) && ( ((e.getY()) > 164)&&((e.getY()) < 178) )){
textArea2.setText("");
textArea2.append("RIGHT1");
textArea1.append("Find COS"); //!!!! work!!
//How to stop the IF cycle here and run class KlikaniMysi (mouselistener) again ?
}
else{
textArea1.setText("");
textArea1.append("try again");
}
}else{
if( (((e.getX()) > 586)&&((e.getX()) < 594)) && ( ((e.getY()) > 174)&&((e.getY()) < 282) )){
//This isnt nice, but I dont know how to expres range better.
textArea1.setText("");
textArea2.append("Right2");
textArea1.append("Find TAN");
}
else{
vystup.setText("");
textArea1.append("Try again");
}
}
}
# 1 楼答案
关于这段代码,还有很多方面是“次优的”,但我认为你的问题在于:
您希望测试该区域的内容,而不是该区域本身,因此将其更改为