I have a HBox in my Javafx application with below configuration
HBox belowBox = new HBox(10); belowBox.getStyleClass().addAll("pane", "vbox"); belowBox.setAlignment(Pos.CENTER); belowBox.getChildren().addAll( .... ); belowBox.setMaxHeight(200); belowBox.setPrefHeight(200); belowBox.setFillHeight(false);
But still if I resize my application the HBox grows vertically. Is there a way to fix the height.
But this is the exact behavior of the HBox layout pane. If you read the HBox documentation, you will see the following:
HBox lays out its children in a single horizontal row...
HBox will resize children (if resizable) to their preferred widths and uses its fillHeight property to determine whether to resize their heights to fill its own height or keep their heights to their preferred (fillHeight defaults to true)...
As said, if for some reason you set the fillHeight property from HBox, you can make the nodes contained within to fill the vacant vertical space, But this will only occur for the nodes that are resizable. For more information about using the JavaFX layout panels, look here. If I'm not mistaken, texts, geometric shapes and ImageView are not resizable objects.