Java Reference
In-Depth Information
subtracting the buttonArea's width (Fluent API). In the example, you also bind the
translateYProperty() based on the scene's height property. Once your but-
tons control is bound, your user will experience user interface goodness. The follow-
ing code uses the Fluent API to bind the button control's properties to the scene's prop-
erties:
// move button group when scene is resized
buttonGroup.translateXProperty().bind(scene.widthProperty().subtract(buttonArea.getWidth() +
6));
buttonGroup.translateYProperty().bind(scene.heightProperty().subtract(buttonArea.getHeight() +
6));
root.getChildren().add(buttonGroup);
15-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.
The news ticker will pause when the mouse hovers over the text, and
will start again once the mouse moves away from the text.
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
Search WWH ::




Custom Search