Java Reference
In-Depth Information
Last but not least, the fade out EventHandler is basically the same as the fade
in, except that the opacity From and To values are from 1.0 to 0.0, which make the
buttons vanish mysteriously when the mouse pointer moves off the scene area.
15-3. Animating Shapes Along a Path
Problem
You want to create a way to animate shapes along a path.
Solution
Create an application that allows users to draw the path for a shape to follow. The main
Java classes used in this recipe are these:
javafx.animation.PathTransition
javafx.scene.input.MouseEvent
javafx.event.EventHandler
javafx.geometry.Point2D
javafx.scene.shape.LineTo
javafx.scene.shape.MoveTo
javafx.scene.shape.Path
The following code demonstrates drawing a path for a shape to follow:
package org.java8recipes.chapter15.recipe15_03;
import javafx.animation.PathTransition;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Scene;
Search WWH ::




Custom Search