title: Change/Update FXML components in another class
body: <p>My problem is: I want to change something from the .fxml but whatever I do, nothing changes. This is just a simply example. </p>
  
  <p>I went trough the whole internet but none of the solutions worked for me.
  Here I want to change the text of the label, by calling the corresponding method from the main class.</p>
  
  <p>Calling the same method (here <code>setLabel()</code>) when clicking a Button, with an event handler in the controller class, everything works fine, but a soon as I try to modify something from another class nothing works.</p>
  
  <p>Main class: </p>
  
  <pre><code>package sample;
  import javafx.application.Application;
  import javafx.application.Platform;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;  
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
  @Override
  public void start(Stage primaryStage) throws Exception{
  
  Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
  primaryStage.setTitle("Hello World");
  primaryStage.setScene(new Scene(root, 300, 275));
  primaryStage.show();
  Controller controller = new Controller();
  Platform.runLater(()-&gt;controller.setLabel());
  
  }
  </code></pre>
  
  <p>FXML Code:
      
      
      
      
      
      
      
      </p>
  
  <pre><code>&lt;BorderPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller"&gt;
     &lt;center&gt;
        &lt;Label fx:id="label" text="This" BorderPane.alignment="CENTER" /&gt;
     &lt;/center&gt;
  &lt;/BorderPane&gt;
  </code></pre>
  
  <p>Controller class:
      package sample;</p>
  
  <pre><code>import javafx.fxml.FXML;
  import javafx.scene.control.Label;
  
  public class Controller {
  @FXML
  private Label label=new Label();
  
  public void setLabel(){
      label.setText("Test");
  }
  }
  </code></pre>