Java Reference
In-Depth Information
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.FlowPane
-alignment: ObjectProperty<Pos>
-orientation:
ObjectProperty<Orientation>
-hgap: DoubleProperty
-vgap: DoubleProperty
The overall alignment of the content in this pane (default:
Pos.LEFT
).
The orientation in this pane (default:
Orientation.HORIZONTAL
).
The horizontal gap between the nodes (default:
0
).
The vertical gap between the nodes (default:
0
).
+FlowPane()
+FlowPane(hgap: double, vgap:
double)
+FlowPane(orientation:
ObjectProperty<Orientation>)
+FlowPane(orientation:
ObjectProperty<Orientation>,
hgap: double, vgap: double
Creates a default
FlowPane
.
Creates a
FlowPane
with a specified horizontal and vertical gap.
Creates a
FlowPane
with a specified orientation.
Creates a
FlowPane
with a specified orientation, horizontal gap and
vertical gap.
F
IGURE
14.15
FlowPane
lays out nodes row by row horizontally or column by column vertically.
Listing 14.10 gives a program that demonstrates
FlowPane
. The program adds labels and
text fields to a
FlowPane
, as shown in FigureĀ 14.16.
L
ISTING
14.10
ShowFlowPane.java
1
import
javafx.application.Application;
2
import
javafx.geometry.Insets;
3
import
javafx.scene.Scene;
4
import
javafx.scene.control.Label;
5
import
javafx.scene.control.TextField;
6
import
javafx.scene.layout.FlowPane;
7
import
javafx.stage.Stage;
8
9
public class
ShowFlowPane
extends
Application {
10 @Override
// Override the start method in the Application class
11
public void
start(Stage primaryStage) {
12
// Create a pane and set its properties
13 FlowPane pane =
new
FlowPane();
14 pane.setPadding(
new
Insets(
11
,
12
,
13
,
14
));
15 pane.setHgap(
5
);
16 pane.setVgap(
5
);
17
18
// Place nodes in the pane
19 pane.getChildren().addAll(
new
Label(
"
First Name:
"
),
20
new
TextField(),
new
Label(
"
MI:
"
));
21 TextField tfMi =
new
TextField();
22 tfMi.setPrefColumnCount(
1
);
23 pane.getChildren().addAll(tfMi,
new
Label(
"
Last Name:
"
),
24
extend
Application
create
FlowPane
add UI controls to pane
new
TextField());
25
26
// Create a scene and place it in the stage
27 Scene scene =
new
Scene(pane,
200
,
250
);
28 primaryStage.setTitle(
"
ShowFlowPane
"
);
// Set the stage title
29
add pane to scene
primaryStage.setScene(scene);
// Place the scene in the stage
place scene to stage
display stage
30
primaryStage.show();
// Display the stage
31 }
32 }
Search WWH ::
Custom Search