Javatpoint Logo
Javatpoint Logo

JavaFX Fill Transition

It animates the node's fill color so that the fill color can fluctuate between the two color values over the specified duration.

In JavaFX, the class javafx.animation.FillTransition represents the Fill Transition. We need to instantiate this class in order to create an appropriate Fill Transition effect.

Properties

The properties of the class along with the setter methods are described in the following table.

Property Description Setter Methods
duration It is an object type property of the class Duration. It represents the duration of the Fill Transition. setDuration(Duration duration)
fromValue It is a double type property. It represents the start color value for the fill transition. setFromValue(Color value)
shape It is an object type property of the class Shape. It represents the shape on which the fill transition is applied. setShape(Shape shape)
toValue This is a double type property. It represents the stop color value for the fill transition. setToValue(Color value)

Constructors

There are five constructors in the class.

  1. public FillTransition() : Creates the instance of FillTransition with the default parameters.
  2. public FillTransition(Duration duration) : Creates the instance of the FillTransition with the specified duration.
  3. public FillTransition(Duration duration, Color fromValue, Color toValue) : creates the instance of FillTransition with the specified duration and the start and end color values.
  4. public FillTransition(Duration duration, Shape shape) : creates the instance of FillTransition with the specified duration and the shape object onto which, it is applied.
  5. public FillTransition(Duration duration, Shape shape, Color fromValue, Color toValue) : creates the new instance of FillTransition with the specified duration, shape and the start and end color values.

Example

In the following example, we have made a polygon and applied Fill Transition on it. The initial color is set to be black while the target color is set to be white. The fill color value of the polygon fluctuates between black and white.

Output:


JavaFX Fill Transition




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA