-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
61 lines (46 loc) · 1.83 KB
/
Main.java
File metadata and controls
61 lines (46 loc) · 1.83 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
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.PasswordField;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
Label titleLabel = new Label("login");
TextField usernameField = new TextField();
//USER NAME LABEL
usernameField.setPromptText("Username");
usernameField.setMaxWidth(280);
PasswordField passwordField = new PasswordField();
//PASSWORD LABEL
passwordField.setPromptText("Password");
passwordField.setMaxWidth(280);
Button loginButton = new Button("Login");
//LoginButton On Action
loginButton.setOnAction(e -> {
if (usernameField.getText().equals("yassine") && passwordField.getText().equals("123")) {
System.out.println("Login successful !");
} else {
System.out.println("Wrong credentials try again ");
}
});
VBox root = new VBox(10);// 10px margin
//Root plays div role simple as that
root.getChildren().addAll(titleLabel,usernameField,passwordField,loginButton);
root.setStyle("-fx-alignment: center ;");// using css to center everything
VBox.setMargin(titleLabel, new Insets(0,0,0,0));
Scene scene = new Scene(root , 350 , 600);
scene.getStylesheets().add(getClass().getResource("styles/MainStyle.css").toExternalForm());
stage.setTitle("LinkedClone App");
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}
public static void main(String[] args) {
launch();
}
}