Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.16 KB | None | 0 0
  1. package UWE;
  2.  
  3. import java.io.IOException;
  4.  
  5. import javafx.event.ActionEvent;
  6. import javafx.fxml.FXML;
  7. import javafx.fxml.FXMLLoader;
  8. import javafx.scene.Node;
  9. import javafx.scene.Parent;
  10. import javafx.scene.Scene;
  11. import javafx.scene.control.Alert;
  12. import javafx.scene.control.PasswordField;
  13. import javafx.scene.control.TextField;
  14. import javafx.stage.Stage;
  15.  
  16. public class LoginScreenController {
  17.  
  18.     public static boolean manager;
  19.     public static boolean wardenOne;
  20.     public static boolean wardenTwo;
  21.     public static boolean wardenThree;
  22.     public static boolean wardenFour;
  23.  
  24.  
  25.     @FXML
  26.     TextField username;
  27.     @FXML
  28.     PasswordField password;
  29.  
  30.  
  31.     private void notAuthorized() {
  32.         Alert alert = new Alert(Alert.AlertType.INFORMATION);
  33.         alert.setContentText("Incorrect Login!");
  34.     }
  35.  
  36.     public void loginEvent(ActionEvent event) throws IOException {
  37.         authorized();
  38.         if (authorized()) {
  39.             Parent root = FXMLLoader.load(getClass().getResource("MainView.fxml"));
  40.             Scene loginScreen = new Scene(root);
  41.             Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
  42.             window.setScene(loginScreen);
  43.             window.show();
  44.         }
  45.         else{
  46.             notAuthorized();
  47.         }
  48.     }
  49.  
  50.  
  51.     public boolean authorized() {
  52.         try {
  53.             if ("manager".equals(username.getText()) && "manager".equals(password.getText())) {
  54.                 manager = true;
  55.             }
  56.             if ("warden1".equals(username.getText()) && "warden1".equals(password.getText())) {
  57.                 wardenOne = true;
  58.             }
  59.             if ("warden2".equals(username.getText()) && "warden2".equals(password.getText())) {
  60.                 wardenTwo = true;
  61.             }
  62.             if ("warden3".equals(username.getText()) && "warden3".equals(password.getText())) {
  63.                 wardenThree = true;
  64.             }
  65.             if ("warden4".equals(username.getText()) && "warden4".equals(password.getText()))
  66.                 wardenFour = true;
  67.         } catch (Exception e) {
  68.             return false;
  69.         }
  70.         return true;
  71.  
  72.     }
  73.  
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement