1 import javafx.application.Application;
2 import javafx.geometry.HPos;
3 import javafx.geometry.Insets;
4 import javafx.geometry.Pos;
5 import javafx.scene.Scene;
6 import javafx.scene.control.Button;
7 import javafx.scene.control.Label;
8 import javafx.scene.control.TextField;
9 import javafx.scene.layout.GridPane;
10 import javafx.stage.Stage;
11
12 public class ShowGridPane extends Application {
13 @Override
14 public void start(Stage primaryStage) {
15
16 GridPane pane = new GridPane();
17 pane.setAlignment(Pos.CENTER);
18 pane.setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
19 pane.setHgap(5.5);
20 pane.setVgap(5.5);
21
22
23 pane.add(new Label("First Name:"), 0, 0);
24 pane.add(new TextField(), 1, 0);
25 pane.add(new Label("MI:"), 0, 1);
26 pane.add(new TextField(), 1, 1);
27 pane.add(new Label("Last Name:"), 0, 2);
28 pane.add(new TextField(), 1, 2);
29 Button btAdd = new Button("Add Name");
30 pane.add(btAdd, 1, 3);
31 GridPane.setHalignment(btAdd, HPos.RIGHT);
32
33
34 Scene scene = new Scene(pane);
35 primaryStage.setTitle("ShowGridPane");
36 primaryStage.setScene(scene);
37 primaryStage.show();
38 }
39
40
44 public static void main(String[] args) {
45 launch(args);
46 }
47 }