HBox is a JavaFX API layout classes which help to display UI controls onto the scene graph. HBox places JavaFX child nodes in a horizontal row. New child nodes are appended to the end on the right side.

HBox lays out its children in a single horizontal row. If the hbox has a border and/or padding set, then the contents will be layed out within those insets. HBox example:

 HBox hbox = new HBox(8); // spacing = 8
 hbox.getChildren().addAll(new Label("Name:), new TextBox());

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). The alignment of the content is controlled by the alignment property, which defaults to Pos.TOP_LEFT.

If an hbox is resized larger than its preferred width, by default it will keep children to their preferred widths, leaving the extra space unused. If an application wishes to have one or more children be allocated that extra space it may optionally set an hgrow constraint on the child. See "Optional Layout Constraints" for details.

HBox lays out each managed child regardless of the child's visible property value; unmanaged children are ignored.

Visual Example

Sample HBox Pane

https://stackru.com/images/7331e4139e6834ff7a328c3f41999583cd718a3d.png

Memory Trick

HBOX = HORIZONTAL BOX

References