1Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> {
2 //what you want to do
3}));
4timeline.setCycleCount(1);//do it x times
5timeline.setCycleCount(Animation.INDEFINITE);//or indefinitely
6
7//play:
8timeline.play();
9//pause:
10timeline.pause();
11//stop:
12timeline.stop();