第二个事件在javafx事件处理中显示得太快

时间:2018-05-09 23:58:13

标签: javafx event-handling

现在,只要用户点击第一个按钮,第二个按钮就会立即出现,有或没有线程。有更好的方法吗?

// 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()));
            }

        });

0 个答案:

没有答案