down = new Button ("Down");
down.setOnAction ( e -> {
TranslateTransition transition = new TranslateTransition();
transition.setDuration(Duration.millis(2500));
transition.setNode(circledd);
transition.setByX(50); //horizontaliai
transition.setByY(0); //Vertikaliai
transition.setAutoReverse(false);
transition.play();
});
我希望如此: 单击“向下”按钮后,图片移动到另一个位置。 当图片移动时,“向下”按钮被禁用(持续3秒)。 之后,“向下”按钮启用(无需用户执行其他操作)
答案 0 :(得分:5)
只需使用动画注册onFinished
处理程序:
down.setOnAction ( e -> {
TranslateTransition transition = new TranslateTransition();
transition.setDuration(Duration.millis(2500));
transition.setNode(circledd);
transition.setByX(50); //horizontaliai
transition.setByY(0); //Vertikaliai
transition.setAutoReverse(false);
down.setDisable(true);
transition.setOnFinished(evt -> down.setDisable(false));
transition.play();
});