现在,只要用户点击第一个按钮,第二个按钮就会立即出现,有或没有线程。有更好的方法吗?
// Register an event filter for a single node and a specific event type
getBtn1().addEventFilter(MouseEvent.MOUSE_CLICKED,
event -> {
if (event.getSource().equals(getBtn1())) {
getBtn1().setGraphic(new ImageView(getCrossImage()));
event.consume();
}
if (event.isConsumed()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
getBtn2().setGraphic(new ImageView(getNoughtsImage()));
}
});