Java Reference
In-Depth Information
F IGURE 14.21
The BorderPane places the nodes in five regions of the pane.
The program defines CustomPane that extends StackPane (line 31). The constructor of
CustomPane adds a label with the specified title (line 33), sets a style for the border color,
and sets a padding using insets (line 35).
The program creates a BorderPane (line 13) and places five instances of CustomPane
into five regions of the border pane (lines 16-20). Note that a pane is a node. So a pane can be
added into another pane. To remove a node from the top region, invoke setTop(null) . If a
region is not occupied, no space will be allocated for this region.
14.10.4 HBox and VBox
An HBox lays out its children in a single horizontal row. A VBox lays out its children in a
single vertical column. Recall that a FlowPane can lay out its children in multiple rows or
multiple columns, but an HBox or a VBox can lay out children only in one row or one column.
The class diagrams for HBox and VBox are shown in FiguresĀ 14.22 and 14.23.
The getter and setter methods for property values
and a getter for property itself are provided in the class,
but omitted in the UML diagram for brevity.
javafx.scene.layout.HBox
-alignment: ObjectProperty<Pos>
-fillHeight: BooleanProperty
-spacing: DoubleProperty
The overall alignment of the children in the box (default: Pos.TOP_LEFT ).
Is resizable children fill the full height of the box (default: true ).
The horizontal gap between two nodes (default: 0 ).
Creates a default HBox .
Creates an HBox with the specified horizontal gap between nodes.
Sets the margin for the node in the pane.
+HBox()
+HBox(spacing: double)
+setMargin(node: Node, value:
Insets): void
F IGURE 14.22
HBox places the nodes in one row.
The getter and setter methods for property values
and a getter for property itself are provided in the class,
but omitted in the UML diagram for brevity.
javafx.scene.layout.VBox
-alignment: ObjectProperty<Pos>
-fillWidth: BooleanProperty
-spacing: DoubleProperty
The overall alignment of the children in the box (default: Pos.TOP_LEFT ).
Is resizable children fill the full width of the box (default: true ).
The vertical gap between two nodes (default: 0 ).
+VBox()
+VBox(spacing: double)
+setMargin(node: Node, value:
Insets): void
Creates a default VBox .
Creates a VBox with the specified horizontal gap between nodes.
Sets the margin for the node in the pane.
F IGURE 14.23
VBox places the nodes in one column.
 
 
Search WWH ::




Custom Search