JavaFX Rotate effect
import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.FlowPane; import javafx.scene.transform.Rotate; import javafx.stage.Stage; public class Main extends Application { private Rotate rotate = new Rotate(); double angle = 0.0; // Create four push buttons. private Button btn = new Button("Click to see effect"); public static void main(String[] args) { launch(args); // w w w . j ava 2s . c om } public void start(Stage myStage) { myStage.setTitle("Effects Demo"); FlowPane rootNode = new FlowPane(10, 10); rootNode.setAlignment(Pos.CENTER); Scene myScene = new Scene(rootNode, 300, 100); myStage.setScene(myScene); btn.getTransforms().add(rotate); btn.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent ae) { // Each time button is pressed, it is rotated 30 degrees // around its center. angle += 30.0; rotate.setAngle(angle); rotate.setPivotX(btn.getWidth()/2); rotate.setPivotY(btn.getHeight()/2); } }); // Add the label and buttons to the scene graph. rootNode.getChildren().addAll(btn); // Show the stage and its scene. myStage.show(); } }