Let's look at the following code and corresponding comments:
// chapter5/basics/BasicAnimation.javapublic void start(Stage stage) { Circle circle = new Circle(50, 150, 50, Color.RED); // change circle.translateXProperty from it's current value to 200 KeyValue keyValue = new KeyValue(circle.translateXProperty(), 200); // over the course of 5 seconds KeyFrame keyFrame = new KeyFrame(Duration.seconds(5), keyValue); Timeline timeline = new Timeline(keyFrame); Scene scene = new Scene(new Pane(circle), 300, 250); stage.setScene(scene); stage.show(); timeline.play();}
It's not very convenient to show how animation works using screenshots, so I really encourage you to run the code from the preceding sample and see it in motion. ...