-
Notifications
You must be signed in to change notification settings - Fork 1
/
GridPaneLoginExample.java
57 lines (43 loc) · 1.46 KB
/
GridPaneLoginExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package sample;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class GridPaneLoginExample extends Application {
Stage window;
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) {
window = stage;
window.setTitle("Grid example");
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(10, 10, 10, 10));
gridPane.setVgap(8);
gridPane.setHgap(10);
//Name lable
Label name = new Label("UserName:");
GridPane.setConstraints(name, 0, 0);
//name input
TextField nameText = new TextField("Pradex"); //Default text
GridPane.setConstraints(nameText, 1, 0);
//Password lable
Label password = new Label("Password:");
GridPane.setConstraints(password, 0, 1);
//Password input
PasswordField passText = new PasswordField(); //Default text
passText.setPromptText("password");
GridPane.setConstraints(passText, 1, 1);
Button submit = new Button("Login");
GridPane.setConstraints(submit, 0, 2);
gridPane.getChildren().addAll(name, nameText, password, passText, submit);
Scene scene = new Scene(gridPane, 300, 200);
window.setScene(scene);
window.show();
}
}