Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gridpane;
- import javafx.scene.control.*;
- import javafx.application.Application;
- import javafx.geometry.HPos;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Scene;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- public class GridPane extends Application{
- @Override
- public void start(Stage stage1){
- GridPane pane = new GridPane();
- pane.setAlignment(Pos.CENTER);
- pane.setPadding(new Insets(11.5, 12.5, 13.5, 14.5)); //pads 4 edges of pane
- pane.setHgap(5.5);
- pane.setVgap(5.5);
- pane.add(new Label("First Name:"), 0,0); //places this in grid position row 0, column 0
- pane.add(new TextField(), 1,0); // in row 0, column 1
- pane.add(new Label("MI:"), 0,1);
- pane.add(new TextField(), 1,1);
- pane.add(new Label("Last Name:"), 0,2);
- pane.add(new TextField(), 1,2);
- pane.add(new Label("Phone Number:"), 0,3);
- pane.add(new TextField(), 1,3);
- Button btAdd = new Button("add Name");
- pane.add(btAdd,1,4);
- GridPane.setHalignment(btAdd, HPos.RIGHT);
- Scene scene = new Scene(pane);
- stage1.setTitle("ShowGridPane");
- stage1.setScene(scene);
- stage1.show();
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment