// the error says and the wordyclient class is below Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774) at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Node.fireEvent(Node.java:8411) at javafx.scene.control.Button.fire(Button.java:185) at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431) at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at com.sun.glass.ui.View.notifyMouse(View.java:937) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:177) at java.lang.Thread.run(Thread.java:750) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:72) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:276) at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769) ... 48 more Caused by: java.lang.NullPointerException at player.WordyClient.loginPressed(WordyClient.java:143) ... 58 more ///////////////////////////////////////////////////////////////////////////////////////// package player; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.stage.Stage; import org.omg.CORBA.ORB; import org.omg.CosNaming.NamingContextExt; import org.omg.CosNaming.NamingContextExtHelper; import server.WordyImpl; import wordyGame.*; import java.io.IOException; import java.util.Scanner; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; public class WordyClient extends Application { public Label globalUsername; @FXML private Button startButton; @FXML private Button closeButton; @FXML private Button loginButton; @FXML private TextField passwordLogin; @FXML private TextField usernameLogin; @FXML private Button startGameButton; @FXML private Button logoutButton; @FXML private Button quitGameButton; @FXML private Label waiting; @FXML private Button a; @FXML private Button b; @FXML private Button c; @FXML private Button d; @FXML private Button e; @FXML private Button f; @FXML private Button g; @FXML private Button h; @FXML private Button i; @FXML private Button j; @FXML private Button k; @FXML private Button l; @FXML private Button m; @FXML private Button n; @FXML private Button o; @FXML private Button p; @FXML private Button q; @FXML private Button enterButton; @FXML private Label answer; @FXML private Button backButton; @FXML private Label invalid; @FXML private Label round; @FXML private Button continueButton; @FXML private Label wlButton; @FXML private Label RWLButton; @FXML private Button RcontinueButton; @FXML private Label countdown; @FXML private Button leaderboardBackBtn; @FXML private TableColumn name; @FXML private TableColumn ranking; @FXML private Button leaderboardButton; static WordyInt impl; static Scanner kbd = new Scanner(System.in); @FXML void startPressed(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("gui/PlayerLogInPage.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("Start Page"); stage.setScene(scene); } @FXML void closePressed(ActionEvent event) { System.exit(0); } @FXML void loginPressed(ActionEvent event) throws IOException { String username = usernameLogin.getText(); String password = passwordLogin.getText(); Player p = new Player(username, password); boolean isLoggedIn = false; try { boolean val = impl.verifyLogin(p); isLoggedIn = val; } catch (invalidUser ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Login Failed"); alert.setContentText("User not found."); alert.showAndWait(); } catch (existingSession ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Existing Session"); alert.setContentText("User is already logged in from another device "); alert.showAndWait(); } catch (invalidCredentials ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Login Failed"); alert.setContentText("Invalid credentials."); alert.showAndWait(); } if (!isLoggedIn) { usernameLogin.clear(); passwordLogin.clear(); } else { FXMLLoader loader = new FXMLLoader(getClass().getResource("gui/PlayerHomePage.fxml")); Parent root = loader.load(); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("WORDY"); stage.setScene(new Scene(root)); stage.show(); Label user = (Label) root.lookup("#globalUsername"); user.setText(username); Label msg = (Label) root.lookup("#waiting"); msg.setText("Start a New Game!"); } } @FXML void startGamePressed(ActionEvent event) throws IOException { FXMLLoader loaderHome = new FXMLLoader(getClass().getResource("gui/PlayerHomePage.fxml")); Parent rootHome = loaderHome.load(); Label msg = (Label) rootHome.lookup("#waiting"); boolean isOngoing = false; try { msg.setText("Waiting for other players to join..."); impl.newGame(globalUsername.getText()); boolean val = impl.getGameState(globalUsername.getText()); isOngoing = val; } catch (noOtherPlayersAvailable ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setHeaderText("Game Error"); alert.setContentText("No players are available. Please try again later."); alert.showAndWait(); } if (!isOngoing){ msg.setText("Start a New Game!"); } else { FXMLLoader loaderMatch = new FXMLLoader(getClass().getResource("gui/PlayerMatchFound.fxml")); FXMLLoader loaderGame = new FXMLLoader(getClass().getResource("gui/PlayerGamePlay.fxml")); Parent rootMatch = loaderMatch.load(); Parent rootGame = loaderGame.load(); ScheduledExecutorService matchFoundDisplay = Executors.newSingleThreadScheduledExecutor(); matchFoundDisplay.schedule(() -> { Node nodeMatch = (Node) event.getSource(); Stage stageMatch = (Stage) nodeMatch.getScene().getWindow(); stageMatch.setTitle("WORDY"); stageMatch.setScene(new Scene(rootMatch)); stageMatch.show(); }, 3, TimeUnit.SECONDS); Node nodeGame = (Node) event.getSource(); Stage stageGame = (Stage) nodeGame.getScene().getWindow(); stageGame.setTitle("WORDY"); stageGame.setScene(new Scene(rootGame)); stageGame.show(); } } @FXML void logoutPressed(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("src/player/gui/PlayerStartPage.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("LoggedIn Page"); stage.setScene(scene); } @FXML void quitGamePressed(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("src/player/gui/PlayerGamePlay.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("GamePlay Page"); stage.setScene(scene); } @FXML void leaderboardBackBtn(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("src/player/gui/PlayerHomePage.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("Home Page"); stage.setScene(scene); } @FXML void leaderboardBtn(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("src/player/gui/leaderboard.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("Leaderboard Page"); stage.setScene(scene); } @FXML void randomLetters(ActionEvent event) { WordyImpl wordyImpl = new WordyImpl(); char[] letters = wordyImpl.generateLetters(); a.setText(new String(letters)); b.setText(new String(letters)); c.setText(new String(letters)); d.setText(new String(letters)); e.setText(new String(letters)); f.setText(new String(letters)); g.setText(new String(letters)); h.setText(new String(letters)); i.setText(new String(letters)); j.setText(new String(letters)); k.setText(new String(letters)); l.setText(new String(letters)); m.setText(new String(letters)); n.setText(new String(letters)); o.setText(new String(letters)); p.setText(new String(letters)); q.setText(new String(letters)); } @FXML void enterPressed(ActionEvent event){ // String enteredWord = answer.getText(); // boolean isValid = verifyWord(enteredWord); // // if (isValid) { // invalid.setText("Great Job!"); // } else { // invalid.setText("Invalid Answer."); // } } @FXML void backPressed(ActionEvent event){ answer.setText(""); } @FXML void RcontinuePressed(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("src/player/gui/PlayerHomePage.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("Result"); stage.setScene(scene); } @FXML void continuePressed(ActionEvent event) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("src/player/gui/PlayerGamePlay.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); Node node = (Node) event.getSource(); Stage stage = (Stage) node.getScene().getWindow(); stage.setTitle("Result Round"); stage.setScene(scene); } @Override public void start(Stage stage) throws Exception { FXMLLoader loader = new FXMLLoader(getClass().getResource("gui/PlayerStartPage.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); stage.setTitle("Wordy"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { try { ORB orb = ORB.init(args, null); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); String name = "WordyApp"; impl = WordyIntHelper.narrow(ncRef.resolve_str(name)); } catch (Exception e) { System.out.println("something is wrong boohoo"); } launch(args); // // // //ALL FOR TESTING LAAANG // // // // System.out.print("Username: "); // String uname = kbd.nextLine(); // System.out.print("Password: "); // String pswd = kbd.nextLine(); // // Player player = new Player(uname, pswd); // // try { // boolean val = impl.verifyLogin(player); // if (val){ // System.out.println("Joining New Game."); // impl.newGame(uname); // while (!impl.getGameState(uname)) { // System.out.println("Game not in progress."); // } // if (impl.getGameState(uname)){ // System.out.println("Game in progress."); // int round = 1; // while (!impl.getWinState(uname)){ // char[] letters = impl.receiveLetters(); // System.out.println(letters); // while (!impl.getGameTime()){ // System.out.print("Enter a word: "); // impl.submitWord(kbd.nextLine(),uname); // } // System.out.println("Round " +round+ " winner: " + impl.getRoundWin(uname)); // round++; // } // System.out.println("Game winner: " + impl.getGameWin(uname)); // // } // // } // } catch (invalidUser e) { // System.out.println("Invalid User"); // } catch (invalidCredentials e) { // System.out.println("Invalid Credentials"); // } catch (existingSession e) { // System.out.println("You are already logged in through another device."); // } catch (noOtherPlayersAvailable e) { // System.out.println("No Players Available."); // } catch (invalidWord e) { // System.out.println("Unrecognized word entered"); // } catch (noSubmittedWord e) { // System.out.println("No words were entered."); // } } }