KeyValue kk2 = new KeyValue(btn.opacityProperty(), stopPosition, Interpolator.LINEAR);
KeyFrame kk = new KeyFrame(Duration.millis(1000),kk2);
KeyValue kk3 = new KeyValue(btn.layoutXProperty(), stopPosition2, Interpolator.LINEAR);
KeyFrame kk4 = new KeyFrame(Duration.millis(5000),kk3);
Timeline timeline = new Timeline();
timeline.getKeyFrames().addAll(kk,kk4);
timeline.setCycleCount(1);
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
timeline.play();
//btn.setVisible(false);
}
});
double stopPosition = 100;
KeyValue kk2 = new KeyValue(nButton1.layoutXProperty(), stopPosition);
KeyFrame kk = new KeyFrame(Duration.millis(5000),kk2);
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(kk);
timeline.setCycleCount(1);
nButton1.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent ae){
timeline.play();
}
});
https://habr.com/post/305282/