Home » javafx Parallel Transition

javafx Parallel Transition

by Online Tutorials Library

JavaFX Parallel Transition

This transition applies multiple animations on a node in parallel. It is similar to Sequential Transition except the fact that it applies multiple transition on a node at the same time while the sequential transition applies the multiple transition on the node by the order in which the animations are passed into the constructor.

In JavaFX, the class javafx.animation.ParallelTransition represents the parallel transition. We just need to pass the list of transitions into the constructor while instantiating this class.

Properties

The class contains only one property that is described in the following table along with its setter method.

Property Description Setter Methods
node This is the property of the type object of class Node. It represents the node onto which the transition is to be applied. setNode(Node node)

Constructors

There are four constructors in the class.

  1. public ParallelTransition() : creates an instance of ParallelTransition with the default parameters.
  2. public ParallelTransition(Animation? children) : creates an instance of ParallelTransition with the list of animations.
  3. public ParallelTransition(Node node) : creates an instance of ParallelTransition with specified node onto which the parallel transition will be applied.
  4. public ParallelTransition(Node node, Animation? children) : creates an instance of ParallelTransition with the specified node and the list of animations.

Example

In the following example, we have created a polygon and applied various animations on it in parallel.

Output:

JavaFX Parallel Transition

Simulating Parallel transition

The following code illustrates the simulation of the parallel transitions on the different nodes. Here, we have applied similar transitions on the different nodes without using ParallelTransition.

Output:

JavaFX Parallel Transition

You may also like