2-2. Generating an Animation

Problem

You want to generate an animation. For example, you want to create a news ticker and photo viewer application with the following requirements:

  • It will have a news ticker control that scrolls to the left.
  • It will fade out the current picture and fade in the next picture as the user clicks the button controls.
  • It will fade in and out button controls when the cursor moves in and out of the scene area, respectively.

Solution

Create animated effects by accessing JavaFX’s animation APIs (javafx.animation.*).To create a news ticker, you need the following classes:

  • javafx.animation.TranslateTransition
  • javafx.util.Duration
  • javafx.event.EventHandler<ActionEvent>
  • javafx.scene.shape.Rectangle

To fade out the current ...

Get JavaFX 2.0: Introduction by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.