Table of contents
1.
Introduction
2.
JavaFX Rotation
2.1.
Types of Constructors
2.2.
Implementation in Java
3.
Frequently Asked Questions
3.1.
Can JavaFX be used without Java?
3.2.
What is new in the latest version of JavaFX?
3.3.
What all do we get if we download JavaFX?
4.
Conclusion
Last Updated: Aug 13, 2025
Medium

JavaFX Rotation

Author Rupal Saluja
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

JavaFX is a platform used in the creation and development of desktop applications and rich web applications so that they run across a wide variety of devices. JavaFX has support for Microsoft Windows, macOS, and Linux. Mobile devices running on iOS and Android also support JavaFX. JavaFX comes with a wide variety of features which includes typeface, Java libraries, JavaFX Script, high availability, transformations it allows, etc. which makes it very convenient to use. In this blog, we will learn about one such in-built transformation available, that is, JavaFX Rotation.

JavaFX Rotation

When we say Rotation, it means to turn the object from its origin. JavaFX Rotation is used for the same, that is, to rotate any object by a certain angle present in the graph screen. The class used to represent translation is javafx.scene.transform.Rotate in which javafx.scene.transform is the parent class. In order to apply various rotation effects, we use this class. It has the ability to rotate any object by rotating its nodes. This rotation is done along a pivot point with a specified angle.

You can refer to the images below for a better understanding.

Before JavaFX Rotation

After JavaFX Rotation

From the images, we could imagine that how actually performing JavaFX rotation would look like. The image has been rotated around a pivot point.

The various properties used to create rotate transformations are mentioned below in the table.

PROPERTIES DESCRIPTION METHOD
axis An axis is an object-type property used to represent the axis of the rotation of the nodes and consequently the object.  setAxis(Point3D value)
angle An angle is a double-type property used to represent the angle by which the object has to be rotated. setAngle(Double value)
pivotX The pivotX is a double-type property used for representation of the x-coordinate of the pivot point.  setPivotX(Double value)
pivotY The pivotY is a double-type property used for representation of the y-coordinate of the pivot point. setPivotY(Double value)
pivotZ The pivotZ is a double-type property used for representation of the z-coordinate of the pivot point. setPivotZ(Double value)

Types of Constructors

The javafx.scene.transform.Rotate class contains six types of constructors. To learn about them, follow these descriptions below.

  1. public Rotate()
    This constructor creates the rotate transform using the default parameters.
     
  2. public Rotate(double angle)
    This constructor creates the rotate transform using the specified angle which is measured in degrees. The pivot points are set to (0,0) by default since the rotation is being done in 2D.
     
  3. public Rotate(double angle, Point3D axis)
    This constructor creates the 3D rotate transform using the specified transform, that is, the angle of rotation and the axis around which the rotation has to be performed is given. The pivot points are set to (0,0,0) by default since the rotation is being done in 3D.
     
  4. public Rotate(double angle, double pivotX, double pivotY)
    This constructor uses three parameters to create the rotate transform using the specified angle and the 2D pivot coordinate (x,y) around which the rotation has to be performed.
     
  5. public Rotate(double angle, double pivotX, double pivotY, double pivotZ)
    This constructor uses four parameters to create the rotate transform using the specified angle and 3D pivot coordinate (x,y,z) around which the rotation has to be performed.
     
  6. public Rotate(double angle, double pivotX, double pivotY, double pivotZ,Point3D Axis)
    This constructor uses five parameters to create a 3D Rotate transform with the specified angle, 3D pivot coordinate (x,y,z) and the axis around which the rotation has to be performed.

Implementation in Java

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;


import java.io.FileInputStream;
import java.io.FileNotFoundException;


//function to implement rotate transformation.
public class RotateTransformationExample extends Application
{
    public static void main(String[] args)
    {
        launch(args);
    }
    //Function to create a figure.
    public void start(Stage primaryStage)
    {
        ImageView imageViewOriginal  = createImageView();
        ImageView imageViewTranslated = createImageView();
        Rotate rotateTransform = new Rotate();
        rotateTransform.setAngle(45);
        rotateTransform.setPivotX(0);
        rotateTransform.setPivotY(0);
        imageViewTranslated.getTransforms().add(rotateTransform);
        Pane pane = new Pane();
        pane.getChildren().add(imageViewTranslated);
        pane.getChildren().add(imageViewOriginal);
        Scene scene = new Scene(pane, 1024, 800, true);
        primaryStage.setScene(scene);
        primaryStage.setTitle("2D Example");
        primaryStage.show();
    }
    //Function to assign memory to the image.
    private ImageView createImageView()
    {
        FileInputStream input = null;
        try {
            input = new FileInputStream("assets/media/abstract-5719221_640.jpg");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        Image image = new Image(input);
        ImageView imageView = new ImageView(image);
        return imageView;
    }
}


On executing the implementation above, we get the output image as:

Frequently Asked Questions

Can JavaFX be used without Java?

No, it is not possible to use JavaFX without Java. You need to have both runtime environments installed to run JavaFX applications. These runtime environments are namely, Java Runtime Environment (JRE) and JavaFX Runtime.

What is new in the latest version of JavaFX?

The latest version of JavaFX contains various vital enhancements necessary to improve the performance, security, and stability of the JavaFX applications that run on your machine. This version will help your applications run safely and more efficiently.

What all do we get if we download JavaFX?

When you download JavaFX, you get JavaFX Runtime along with it. This runtime consists of a set of several Java Libraries which helps you enable modern-looking user interfaces as well as specific to the operations which will access hardware resources.

Conclusion

In a nutshell, we understood what is JavaFX Rotation, saw the properties used for its creation, learned about various constructors offered and seen its example implementation in Java.

We hope the above discussion helped you understand JavaFX Rotation in clearer terms and can be used for future reference whenever needed. For a crystal understanding of JavaFX, you can refer to our blog on JavaFX. It is highly recommended to go through these blogs on Core JavaBasics of Java and Java Data Structures and Algorithms before going deep into learning JavaFX.

Visit our website to read more such blogs. Make sure that you enroll in the courses provided by us, take mock tests and solve problems available and interview puzzles. Also, you can pay attention to interview stuff- interview experiences and an interview bundle for placement preparations. Do upvote our blog to help fellow ninjas grow.

Happy Coding!

Live masterclass