Repository navigation
Expand file tree
/
Copy pathJavaFXDemoVideo5.java
More file actions
124 lines (104 loc) · 3.53 KB
/
Copy pathJavaFXDemoVideo5.java
File metadata and controls
124 lines (104 loc) · 3.53 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package javafxdemovideo5;
import static java.awt.SystemColor.window;
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.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFXDemoVideo5 extends Application{
Stage window;
public static void main(String[] args) {
//multiple windows
launch(args);
}
//Tutorial 9
//GridPanes layout
@Override
public void start(Stage PrimaryStage){
window = PrimaryStage;
window.setTitle("JavaFX - The New Boston");
GridPane grid = new GridPane();
//spacing
grid.setPadding(new Insets(10, 10, 10, 10));
//virticle spacing
grid.setVgap(8);
//horizontal spacing
grid.setHgap(10);
//name label
Label nameLabel = new Label("Username:");
GridPane.setConstraints(nameLabel, 0, 0);
//name input
TextField nameInput = new TextField("Bucky");
GridPane.setConstraints(nameInput, 1, 0);
//password label
Label passLabel = new Label("Password:");
GridPane.setConstraints(passLabel, 0, 1);
//name input
TextField passInput = new TextField();
passInput.setPromptText("password");
GridPane.setConstraints(passInput, 1, 1);
Button login = new Button("Login");
GridPane.setConstraints(login, 1, 2);
grid.getChildren().addAll(nameLabel, nameInput, passLabel, passInput, login);
Scene scene = new Scene(grid, 300, 200);
window.setScene(scene);
window.show();
}
// Tutorial 5-8{alert confirm and layout}
// Button button;
// public static void main(String[] args) {
// //multiple windows
// launch(args);
// }
//
// @Override
// public void start(Stage PrimaryStage){
// window = PrimaryStage;
// window.setTitle("JavaFX - The New Boston");
// window.setOnCloseRequest(e -> {
// //consumes the request
// e.consume();
// closeProgram();
// });
//
//
//// button = new Button("Close Program");
//// button.setOnAction(e -> {
//// closeProgram();
//// });
//
// HBox topMenu = new HBox();
// Button buttonA = new Button("File");
// Button buttonB = new Button("Edit");
// Button buttonC = new Button("View");
// topMenu.getChildren().addAll(buttonA, buttonB, buttonC);
//
// VBox leftMenu = new VBox();
// Button buttonD = new Button("D");
// Button buttonE = new Button("E");
// Button buttonF = new Button("F");
// leftMenu.getChildren().addAll(buttonD, buttonE, buttonF);
//
// BorderPane borderPane = new BorderPane();
// borderPane.setTop(topMenu);
// borderPane.setLeft(leftMenu);
//
//// StackPane layout = new StackPane();
//// layout.getChildren().add(button);
// Scene scene = new Scene(borderPane, 300, 250);
// window.setScene(scene);
// window.show();
//
// }
//
// private void closeProgram(){
// Boolean answer = Confirmbox.display("Title", "are you sure you want to do that?");
// if(answer){
// window.close();
// }
// }
}