80
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.
- public StokeTransition() : Creates the new instance of StrokeTransition with the default parameters.
- public StokeTransition(Duration duration) : Creates the new instance of Stroke Transition with the specified duration value
- 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.
- 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.
- 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:
Next TopicJavaFX Sequential Transition