List of usage examples for javafx.scene.image ImageView setViewport
public final void setViewport(Rectangle2D value)
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("HTML"); stage.setWidth(500);//w w w .j a v a 2 s .co m 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); Rectangle2D viewportRect = new Rectangle2D(40, 35, 110, 110); selectedImage.setViewport(viewportRect); root.getChildren().addAll(selectedImage); scene.setRoot(root); stage.setScene(scene); stage.show(); }