package login;
public class loginAppController implements Initializable {
loginModel loginModel = new loginModel();
@FXML
private JFXButton loginButton;
@FXML
private Label dbStatus;
@FXML
private JFXTextField email;
@FXML
private JFXPasswordField password;
@FXML
private JFXComboBox<option> combobox;
@FXML
public Label loginStatus;
@FXML
public void initialize(URL location, ResourceBundle resources) {
if(this.loginModel.isDatabaseConnected()) {
this.dbStatus.setText("Connected To Database");
} else {
this.dbStatus.setText("Not Connected To Database");
}
this.combobox.setItems(FXCollections.observableArrayList(option.values()));
}
@FXML
public void Login(ActionEvent event) throws Exception {
try {
if (this.loginModel.isLogin(this.email.getText(), this.password.getText(), ((option) this.combobox.getValue()).toString())) {
Stage stage = (Stage) this.loginButton.getScene().getWindow();
stage.close();
switch (((option) this.combobox.getValue()).toString()) {
case "Admin":
adminLogin();
break;
case "Student":
studentLogin();
break;
}
} else {
this.loginStatus.setText("Wrong Data");
}
} catch (Exception localException) {
}
}
public void studentLogin() {
try {
Stage userStage = new Stage();
FXMLLoader loader = new FXMLLoader();
Pane root = (Pane) loader.load(getClass().getResource("/Users/Alar/Desktop/SMS/src/main/resources/students/studentFXML.fxml").openStream());
StudentsController studentsController = (StudentsController) loader.getController();
Scene scene = new Scene(root);
userStage.setScene(scene);
userStage.setTitle("Student Dashboard");
userStage.setResizable(false);
userStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
public void adminLogin() {
try {
Stage adminStage = new Stage();
FXMLLoader adminLoader = new FXMLLoader();
Pane adminroot = (Pane) adminLoader.load(getClass().getResource("/Users/Alar/Desktop/SMS/src/main/resources/Admin/Admin.fxml").openStream());
AdminController adminController = (AdminController) adminLoader.getController();
Scene adminscene = new Scene(adminroot);
adminStage.setScene(adminscene);
adminStage.setTitle("Admin Dashboard");
adminStage.setResizable(true);
adminStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Когда я ввожу данные для входа в систему, я отлаживаю их, и приложение переходит с
Pane adminroot = (Pane) adminLoader.load(getClass().getResource("/Users/Alar/Desktop/SMS/src/main/resources/Admin/Admin.fxml").openStream());
на
catch (Exception localException) { }
, и оно не открывает новое окно.То же самое происходит для studentLogin()
.
Любая помощь будет очень ценится
Спасибо