rotate a text 30 degrees around the Z-axis at anchor point of (50,30) : Rotate « JavaFX « Java






rotate a text 30 degrees around the Z-axis at anchor point of (50,30)

 

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage stage) {
        Group root = new Group();
        Scene scene = new Scene(root, 500, 200);
        stage.setScene(scene);

        Text text = new Text("This is a test");
        text.setX(10);
        text.setY(50);
        text.setFont(new Font(20));

        text.getTransforms().add(new Rotate(30, 50, 30));
        
        root.getChildren().add(text);

        stage.show();
        
    }
    public static void main(String[] args) {
        launch(args);
    }
}

   
  








Related examples in the same category

1.Rotation on Z index
2.rotate by 45 degrees