/* /Check of de naam in de database gelijk is aan de textveld tfBeginUsername */ @FXML public void Login() throws IOException, SQLException, NotBoundException { try { // check if the user is already online. for (User usr : loginIn.getOnlineUsers()) { if (usr.getName().equals(tfBeginUsername.getText())) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("User is already online"); alert.showAndWait(); } else if (loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()) != null) { user = loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()); LobbySession.user = user; userName = user.getName(); LbLobbyUserName.textProperty().bind(userNameProperty); loginIn.addToOnline(LobbySession.user); stage = (Stage) btBeginLogIn.getScene().getWindow(); root = FXMLLoader.load(getClass().getResource("Lobby.fxml")); Scene scene = new Scene(root); scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm()); stage.setScene(scene); stage.setResizable(false); stage.show(); } else { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("Please enter correct name and password"); alert.showAndWait(); } } if (loginIn.getOnlineUsers().isEmpty()) { user = loginIn.Login(tfBeginUsername.getText(), tfBeginPassword.getText()); LobbySession.user = user; userName = user.getName(); LbLobbyUserName.textProperty().bind(userNameProperty); loginIn.addToOnline(LobbySession.user); stage = (Stage) btBeginLogIn.getScene().getWindow(); root = FXMLLoader.load(getClass().getResource("Lobby.fxml")); Scene scene = new Scene(root); scene.getStylesheets().add((new File("css/Lobby.css")).toURI().toURL().toExternalForm()); stage.setScene(scene); stage.setResizable(false); stage.show(); } } catch (Exception ex) { System.out.println("Not working: " + ex); } }