JavaFX Fade Transition

It animates the opacity of the node so that the fill color of the node becomes dull. This can be done by keep decreasing the opacity of the fill color over a specified duration in order to reach a target opacity value.

In JavaFX, the class javafx.animation.FadeTransition represents FadeTransition. We need to instantiate this class in order to create the appropriate Fade Transition.

Properties

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

PropertyDescriptionSetter Methods
byValueIt is a double type property. It represents the incremented stop opacity value of the Fade transition.setByValue(double property)
DurationThis is an object type property of the class Duration. It represent the duration of this fade transition.setDuration(Duration duration)
fromValueThis is a double type property. It represents the start opacity for the fade transition.setFromValue(double value)
nodeThis is an object type property of the class Node. This represents the node onto which, the transition is to be applied.setNode(Node node)
toValueThis is a double type property. This represents the stop value of the opacity for the fade transition.setToValue(double value)

Constructors

The class contains three Constructors.

  1. public TranslateTransition() : creates the new instance of TranslateTransition with the default parameters.
  2. public TranslateTransition(Duration duration) : creates the new instance of TranslateTransition with the specified duration.
  3. public TranslateTransition(Duration duration, Node node) : creates the new instance of Translate Transition with the specified duration and node.

Example

In the following example, the opacity of the color of the circle keeps decreasing from the 10 to 0.1.

Output:


JavaFX Fade Transition




Latest Courses