Javafx HBox restrict to specific height


I have a HBox in my Javafx application with below configuration

 HBox belowBox = new HBox(10);
 belowBox.getStyleClass().addAll("pane", "vbox");
 belowBox.getChildren().addAll( .... );

But still if I resize my application the HBox grows vertically. Is there a way to fix the height.

Thank you

1/19/2014 6:22:45 AM

Accepted Answer

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...

And also:

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.

1/20/2014 1:18:50 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow