JavaFX HBox

HBox layout pane arranges the nodes in a single row. It is represented by javafx.scene.layout.HBox class. We just need to instantiate HBox class in order to create HBox layout.

Properties

The Properties of the class along with their setter methods are given in the table below.

PropertyDescriptionSetter Methods
alignmentThis represents the alignment of the nodes.setAlignment(Double)
fillHeightThis is a boolean property. If you set this property to true the height of the nodes will become equal to the height of the HBox.setFillHeight(Double)
spacingThis represents the space between the nodes in the HBox. It is of double type.setSpacing(Double)

Constructors

The HBox class contains two constructors that are given below.

  1. new HBox() : create HBox layout with 0 spacing
  2. new Hbox(Double spacing) : create HBox layout with a spacing value

Example


JavaFX HBox Output1

Example : Setting the space among the nodes.


JavaFX HBox Output2
Next TopicJavaFX VBox




Latest Courses