title: changing javafx label from one stage to another
body: <p>I want to be able to pass a string from one stage to another stage using javafx and fxml. This seems to be an easy task for everyone else, but when i try the same code/same methods, it seems to throw a 'java.lang.reflect.invocationTargetException'. I am quite new to Java and so I'd appreciate all the explanation you can give!</p>
  
  <p><strong>This code is from the login screen, passing the string to the new stage</strong>  </p>
  
  <pre><code>        FXMLLoader myLoader = new FXMLLoader(getClass().getResource("dashboard.fxml"));
          Parent dashboardParent = FXMLLoader.load(getClass().getResource("dashboard.fxml"));
          DashboardController dashboardController = myLoader.getController();
  
          Scene dashboardScene = new Scene(dashboardParent);
          Stage window = new Stage();
          Stage currentWindow = (Stage)((Node)event.getSource()).getScene().getWindow();
          currentWindow.close();
          dashboardController.changeLabel("Hello World");
          window.setScene(dashboardScene);
          window.show();
  </code></pre>
  
  <p><strong>This code is the 'changeLabel' method in the scene, that we are changing the label</strong></p>
  
  <pre><code>public void changeLabel(String labelText){
      stockCountLbl.setText(labelText);
  }
  </code></pre>
  
  <p><strong>Line throwing the exception and stack trace</strong></p>
  
  <pre><code>dashboardController.changeLabel("Hello World");
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>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:54)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3470)
  at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3398)
  at javafx.scene.Scene$MouseHandler.process(Scene.java:3766)
  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$353(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$147(WinApplication.java:177)
  at java.lang.Thread.run(Thread.java:748)
  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:71)
  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:275)
  at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
  ... 31 more
  Caused by: java.lang.NullPointerException
  at bownhrmain1.pages.LoginScreenController.clickLogin(LoginScreenController.java:90)
  ... 41 more
  </code></pre>