Home » javafx Stroke Transition

javafx Stroke Transition

by Online Tutorials Library

JavaFX StrokeTransition

It animates the node’s stroke color so that the stroke 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.

Properties

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

Property Description Setter Methods
duration This is an object type property of the class Duration. It represents the duration of the stroke Transition. setDuration(Duration duration)
fromValue This is a color type property. It represents the initial value of the color for the stroke transition. setFromValue(Color value)
shape This is an object type property of the class Shape. It represents the shape onto which the Stroke transition will be applied. setShape(Shape shape)
toValue This is color type property. It represents the target value of the color for the stroke transition. setToValue(Color value)

Constructors

There are five constructors in the class.

  1. public StokeTransition() : Creates the new instance of StrokeTransition with the default parameters.
  2. public StokeTransition(Duration duration) : Creates the new instance of Stroke Transition with the specified duration value
  3. public StokeTransition(Duration duration, Color fromValue, Color toValue) : creates the new instance of StrokeTransition with the specified duration, the initial value of the color and the target value of the color.
  4. public StokeTransition(Duration duration, Shape shape) : creates the new instance of StrokeTransition with the specified duration and the shape onto which, the transition is to be applied.
  5. 5public StokeTransition(Duration duration, Shape shape, Color fromValue, Color toValue) : creates the new instance of StrokeTransition with the specified duration, shape, initial value of the color and target value of the color.

Example

In the following example, the stroke of the circle fluctuates from black to purple.

Output:

JavaFX Stroke Transition

You may also like