i am facing problem to developed a demo JavaFX program for image viewing as a newbie. here i have an ImageView in BorderPane center position which is wrapped with a StackPane and VBox. where StackPane is always grow with VBox and i bind ImageView with StackPane Width and Height property so that my ImageView will change its setFitHeight and Weight when i resize window. it works fine as i want but problem is when window resized from maximum the image don't resize its Height. i found that StackPane's heightProperty change listener don't call. So i to solve this problem to archive my goal.? is its some kinds JavaFX bug or my lacking knowledge?
here is my fxml code for image view:
<center>
<VBox fx:id="imageVBox" alignment="CENTER" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets />
</BorderPane.margin>
<StackPane fx:id="stackPane" VBox.vgrow="ALWAYS">
<ImageView fx:id="imageView" fitHeight="250.0" fitWidth="300.0" nodeOrientation="INHERIT" onDragDropped="#getDragImage" onDragOver="#dragOver" pickOnBounds="true" preserveRatio="true" StackPane.alignment="CENTER">
<viewport>
<Rectangle2D />
</viewport>
</ImageView>
</StackPane>
</VBox>
my java code which bind ImageView with StackPane:
imageView.fitWidthProperty().bind(stackPane.widthProperty());
imageView.fitHeightProperty().bind(stackPane.heightProperty());
the problem i faced:
- my program window when i run it
- maximize window
- when i resize it to default the problem occured, image don't resize as expected