0

I have a login application->(Login) that starts when i run the program in Netbeans, When login credentials are verified i hide the stage and start another stage->(Stardust).

I have a label in Stardust that is initially empty but after login should show the username. I have seen countless questions regarding this and most of the answers didn't even work for the one who asked so forgive me if you find this duplicate.

I have created a method for taking the username from Login into Stardust but when i try : label.setText(user); it gives a NullPointerException image as you can see when i am printing i get the name but it is not setting as label's text. Also if possible i would like this task to happen when this method is called.

//Requested Code

'static void launcher() {
        Platform.runLater(new Runnable() {
   public void run() {             
       new Stardust().start(new Stage());     
   }
});
}'  

I called it like Login.launcher(); when login is successful in LoginController.java

public static void main(String[] args) {
        Application.launch(Login.class);

}

is how i launch the Login from Stardust

KnightHood
  • 55
  • 1
  • 8
  • Can you show the code where you start the other stage? – Hypnic Jerk Dec 29 '16 at 19:26
  • 1
    Edit your question and post your code. FXML, controllers, etc. – Hypnic Jerk Dec 29 '16 at 19:30
  • 1
    If `label.setText(user);` results in a NPE, if `label` is `null`. I dupehammered this question since it lacks any description about how `label` is supposed to be assigned - or even if it's a field, local variable or the class/method it recides in.... – fabian Dec 29 '16 at 20:09

0 Answers0