JavaFX Scale Transition

This transition animates the scaling of the node over the specified duration by the specified factor in any or all of the three directions X, Y, and Z.

In JavaFX, ScaleTransition is represented by the class javafx.animation.ScaleTransition. We need to instantiate this class in order to generate an appropriate scale transition.

Properties

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

PropertyDescriptionSetter Methods
byXThis is a double type property. It represents the incremented stop X factor value.setByX(double value)
byYThis is a double type property. It represents the incremented stop Y factor value.setByY(double value)
byZThis is a double type property. It represents the incremented stop Z factor value.setByZ(double value)
durationThis is an object type property of the class Duration . It represents the duration of scale transition.setDuration(Duration value)
fromXThis is a double type property. It represents the start X value of ScaleTransition.setFromX(double value)
fromYThis is a double type property. It represents the start Y value of ScaleTransition.setFromY(double value)
fromZThis is a double type property. It represents the start Z value of ScaleTransition.setFromZ(double value)
nodeThis is an object type property of the class Node. It represents onto which, the scale transition is applied.setNode(Node node)
toXThis is a double type property. It represents the stop X scale value of the scale transition.setToX(double value)
toYThis is a double type property. It represents the stop Y scale value of the scale transition.setToY(double value)
toZThis is a double type property. It represents the stop Z scale value of the scale transition.setToZ(double value)

Constructors

There are three constructors in the class.

  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, we have made a circle translating itself by 400 in the X direction.

Output:


JavaFX Scale Transition




Latest Courses