O'Reilly logo

JavaFX 2.0: Introduction by Example by Carl Dea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required