-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFXMLDocumentController.java
More file actions
60 lines (52 loc) · 1.92 KB
/
FXMLDocumentController.java
File metadata and controls
60 lines (52 loc) · 1.92 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
package quizapp;
import javafx.fxml.FXMLLoader;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.PasswordField;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.io.IOException;
public class FXMLDocumentController implements Initializable {
@FXML
private Button EnterButton;
@FXML
private TextField Username;
@FXML
private PasswordField Password;
@Override
public void initialize(URL url, ResourceBundle rb) {
// Initialization code here
}
@FXML
private void handleEnterButton(ActionEvent event) {
try {
if (Username.getText().equals("Admin123") && Password.getText().equals("Seecs@123")) {
Stage thisStage = (Stage) EnterButton.getScene().getWindow();
thisStage.close();
Scene scene = new Scene(FXMLLoader.load(getClass().getResource("QuizScreen.fxml")));
Stage stage = new Stage();
stage.setScene(scene);
stage.initStyle(StageStyle.TRANSPARENT);
scene.setFill(Color.TRANSPARENT);
stage.show();
} else {
Alert errorAlert = new Alert(AlertType.ERROR);
errorAlert.setTitle("Error Message");
errorAlert.setHeaderText(null); // Optional: remove header
errorAlert.setContentText("Error! Invalid Username or Password.");
errorAlert.showAndWait();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}