How do I get an image in an ImageView to automatically resize such that it always fits the parent node?
Here is a small code example:
@Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); ImageView img = new ImageView("http://..."); //didn't work for me: //img.fitWidthProperty().bind(new SimpleDoubleProperty(stage.getWidth())); pane.setCenter(img); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); }
@Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); ImageView img = new ImageView("http://..."); img.fitWidthProperty().bind(stage.widthProperty()); pane.setCenter(img); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With