Rotate ImageView : ImageView « JavaFX « Java






Rotate ImageView

 
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
 
public class Main extends Application {

    @Override
    public void start(Stage stage) {
        stage.setTitle("HTML");
        stage.setWidth(500);
        stage.setHeight(500);
        Scene scene = new Scene(new Group());
        VBox root = new VBox();    

        final ImageView selectedImage = new ImageView();   
        Image image1 = new Image(Main.class.getResourceAsStream("a.jpg"));
        selectedImage.setImage(image1);
        
        selectedImage.setRotate(90);
        
        root.getChildren().addAll(selectedImage);
        
        scene.setRoot(root);
 
        stage.setScene(scene);
        stage.show();
    }
 
    public static void main(String[] args) {
        launch(args);
    }
}

   
  








Related examples in the same category

1.Using ImageView to display image
2.Load a jpg image with Image and use ImageView to display
3.setFitWidth for ImageView
4.setPreserveRatio for ImageView
5.Load Image from URL
6.JavaFX Image Zoom Example