Introduction
In Java, animation consists of two fundamental steps: constructing an animation frame and then enabling Java to color the frame. Applets, AWT, Swing, and JavaFX may all be used to create animation in Java. Applet animation is used in browser-based applications, whereas AWT, Swing, and JavaFX are standalone apps. The majority of real-time apps are stand-alone. So we'll use JavaFX to manage our animation.
JavaFX Animation
In general, Animation is described as the transition that produces the illusion of motion for an object. It is the sequence of modifications made to an item over a specific time period to portray the thing in motion.
This may be accomplished by the fast presentation of frames. The package javafx.animation in JavaFX comprises all the classes used to apply animations to nodes. Every class in this package extends the class javafx.animation.Animation.
JavaFX has transition classes such as RotateTransition, ScaleTransition, TranslateTransition, FadeTransition, FillTransition, StrokeTransition, and others.
Basic Transitions
The javafx.animation package includes classes for performing the following transitions.

How Does JavaFX Animation Work in Java?
A JavaFX animation package comprises all of the animation classes. As a result, we must import animations while applying them. We must extend the Animation class to add animations to our class. This Animation class contains all of the necessary animation packages.
Rotate Transition
This animation has a rotating characteristic. The package is animation.RotateTransition.
RotateTransition rotate = new RotateTransition(); //creating object for rotate transition
rotate.play();//using the play method to apply rotationScale Transition
The object in this animation moves in all three directions (X, Y, and Z). The package is animation.ScaleTransition.
ScaleTransition scale = new ScaleTransition(); //creating object for scale transition
scale.play(); //using the play method to apply scale transitionTranslate Transition
This animation shifts the object from one position to another at regular intervals of time. The package is animation.TranslateTransition.
TranslateTransition translate = new TranslateTransition(); //creating object for Translate transition
translate.play(); //using the play method to apply translate transitionFade Transition
By specifying the opacity value, this animation dulls the object. The package is animation. FadeTransition.
FadeTransition fade = new FadeTransition(); //creating object for fade transition
fade.play(); //using the play method to apply fade transitionFill Transition
By choosing the time interval, this animation causes the object to fill with two colors, one after the other. The package is animation. FillTransition.
FillTransition fill = new FillTransition(); //creating object for fill transition
fill.play(); //using the play method to apply fill transitionSteps for applying Animations
Create the destination node and set its properties.
Polygon traingle = new Polygon();
Double[] doubleValues=new Double[] { 60.0, 60.0, 200.0, 100.0, 100.0, 200.0 };
traingle.getPoints().addAll(doubleValues);
traingle.setFill(Color.LIGHTGREEN);Instantiate the corresponding transition class.
RotateTransition rotateTransition = new RotateTransition();Set the transition's desired attributes such as duration, cycle-count, etc.
rotateTransition.setAxis(Rotate.X_AXIS);
rotateTransition.setByAngle(360);
rotateTransition.setCycleCount(500);
rotateTransition.setDuration(Duration.millis(1000));Set the target node for the transition to be applied to. For this purpose, use the following method.
rotateTransition.setNode(traingle);Finally, use the play() method to play the transition.
rotateTransition.play();







