title: Update FXML Screen
body: <p>I want to update a Screen, which i created with a FXML-file.</p>
  
  <p>I though this: <a href="https://stackoverflow.com/questions/10751271/accessing-fxml-controller-class">Link</a> was the solution, but i dont get the code to run. I found some other parts of code but no one worked for me. I am not shure if i use a different version (see <a href="https://stackoverflow.com/questions/9717852/how-to-pass-object-created-in-fxml-controller1-to-controller2-of-inner-fxml-cont/10718683#10718683">Link</a>) or maybe i am just an idot... but we will see...</p>
  
  <p>I made a very simple exampel to show my problem, so that hopefully someone can show me on this simple example how it works.</p>
  
  <p>JavaFXApplication.java</p>
  
  <pre><code>package javafxapplication;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class JavaFXApplication extends Application {
  
      @Override
      public void start(Stage stage) throws Exception {
          Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
          Scene scene = new Scene(root);
          stage.setScene(scene);
          stage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  
  }
  </code></pre>
  
  <p>FXMLDocumentController.java</p>
  
  <pre><code>package javafxapplication;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.Label;
  
  public class FXMLDocumentController implements Initializable {
  
      @FXML
      private Label label;
  
      @Override
      public void initialize(URL url, ResourceBundle rb) {
          label.setText("This Label was initialized.");
      }    
  
      public void update(){
          label.setText("This Label was updated :)"); //Just4Example... normaly here is some SQL-Stuff...
      }
  
  }
  </code></pre>
  
  <p>FXMLDocument.fxml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  
  &lt;AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication.FXMLDocumentController"&gt;
      &lt;children&gt;
          &lt;Label layoutX="100" layoutY="100" minHeight="16" minWidth="69" fx:id="label" /&gt;
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>I want to start the "update"-Methode in the controller every 5 seconds. But when i use a Timer to do this... the Controller is gone. So when the Timer starts the Methode there are no @FXML connections... Maybe the Controller should created manualy... or linke the second linke... but i dont get the code to run... confused... frustrated...</p>
  
  <p>Thank you very much</p>