title: javafx transfer text from label across screens
body: <p>I've searched and I'm sure that others have this problem as well. Many of the posts are unanswered or down voted and no solution is given, even to my own post. I wanted to know how I could transfer label data among classes. For example, say I have the following:</p>
  
  <p>First Class:</p>
  
  <pre><code>Label lab;
  public void setText() {
     lab.setText("hello");
  }
  public String getText() {
     return lab.getText();
  }
  public void switchScene(ActionEvent event) throws IOException {
  //code to switch scenes when button pressed
  setText(); //this is also called when button pressed
  
  }
  </code></pre>
  
  <p>Middle Class:</p>
  
  <pre><code>public void switchScenes(ActionEvent event) throws IOException {
      FirstScreenController p = new FirstScreenController();
      n.displayAmt(p.getText()); //get text from first scene's label
  }
  </code></pre>
  
  <p>Target Class:</p>
  
  <pre><code>Label otherLab;
  public void displayAmt(String amt) {
      otherLab.setText(amt); //set text from first scene's label to this label
  }
  </code></pre>
  
  <p>Suppose the middle class method is set to a button. Upon clicking the button, everything seems to work fine as the program switches scenes. However, otherLab in the Target class is empty. The text from the label in the first class was unsuccessfully transferred to the label in the target class. </p>
  
  <p>How would one go about fixing this? I know that java is pass-by-value so the first label wont carry changes made by the function. What can be done to overcome this? </p>