/* /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); } }
private void fillUserList() throws RemoteException { userList.clear(); if (loginIn.getOnlineUsers() != null) { for (User onlineUser : loginIn.getOnlineUsers()) { userList.add(onlineUser.getName()); } } }
@FXML public void newUser(Event evt) throws SQLException, RemoteException { if (tfNewUserUsername.getText().equals("") || tfNewUserPassword.getText().equals("")) { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information Dialog"); alert.setHeaderText("Please fill in username and password"); alert.showAndWait(); } else { loginIn.registerUser(tfNewUserUsername.getText(), tfNewUserPassword.getText()); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText( tfNewUserUsername.getText() + " your account has been succesfully created"); alert.showAndWait(); } }
private void fillPlayerList() throws RemoteException { tempgamePlayers.clear(); if (gameManager.getGames().size() >= 1) { if (LobbySession.game != null) { for (IGame g : gameManager.getGames()) { if (LobbySession.game.getGameID() == g.getGameID()) { if (g.getGameID() == LobbySession.game.getGameID()) { for (Player s : g.getPlayers()) { for (User u : loginIn.getOnlineUsers()) { if (s.getUserID() == u.getUserID()) { tempgamePlayers.add(u.getName()); // System.out.println("Players in playerlist::" + tempgamePlayers.toString()); } } } } } } } } gamePlayers = tempgamePlayers; }