title: Change label text in a new scene which was entered in different scene (javafx)
body: <p>I'm trying to change a text in a label, a text which was entered in a text field in a different scene.
  I made 2 FXML files, the first one contains a textfield and "ok" button, the second one contains a label(with the text "Label"). 
  My goal is to enter a text in the textfield, and when I press "ok"-> open the new scene and the label will change it's text to the text I entered in the text field.
  I easily changed the label text when the label, the textfield and the ok button were all in the same scene, but when I do it while opening a new scene I fail...
  After some research, I made a controller for each FXML file, and a "MainController" that will communicate between them. 
  This is my main class:</p>
  
  <pre><code>public class MainBanana extends Application {
  
  
  @Override
  public void start(Stage primaryStage) throws IOException {
  
      Parent root = FXMLLoader.load(getClass().getResource("view/Welcome.fxml"));
      Scene scene = new Scene(root);
      primaryStage.setTitle("MokaApp");
      primaryStage.setScene(scene);
      primaryStage.show();
      primaryStage.setResizable(false);
  
  
  
  }
  
  public static void main(String[] args) {
      launch(args);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>my first scene controller:</p>
  
  <pre><code>public class WelcomeController {
  
  @FXML
  public TextField nameField;
  @FXML
  private Button okButton;
  
  private MainController main;
  
  
  @FXML
  public void okClicked(ActionEvent event) throws IOException{
  
  
  
      Parent root = FXMLLoader.load(getClass().getResource("Person.fxml"));
      okButton.getScene().setRoot(root);
      System.out.println(nameField.getText());
      main.setLblFromTf(nameField.getText());
  
  
  }
  
  
      public void init(MainController mainController) {
          main=mainController;
  
      }
  </code></pre>
  
  <p>}</p>
  
  <p>second scene controller:</p>
  
  <pre><code>public class PersonController {
  
  @FXML
  public Label nameLabel;
  
  private MainController main;
  
  
  public void init(MainController mainController) {
      main=mainController;
  
  }
  
  }
  </code></pre>
  
  <p>When I launch the program, The Welcome scene is opened, I enter a text to the textfield, but whenever I press the "ok" button, the scene changes to the second scene, but the label text stays the same(label) and I get a nullpointerexception error on this line(located in WelcomeController): main.setLblFromTf(nameField.getText());</p>
  
  <p>Sorry for the long post..</p>