title: JavaFX can't edit text
body: <p>I have: 2 FXML Files, and 2 Controllers. Each FXML's have the controllers merged. This is the code opening the new FXML (While the real fxml is running it opens another one)</p>
  
  <pre><code>try {
              Parent root = FXMLLoader.load(getClass().getResource(
                      "settings.fxml"));
           Stage stage = new Stage();
           stage.setScene(new Scene(root));  
           stage.centerOnScreen();
           stage.show();
          } catch (Exception e) {
              e.printStackTrace();
              Logger.logCrash("ApplicationScene", e);
          }
  </code></pre>
  
  <p>This is the controller of the FXML file which gets opened</p>
  
  <pre><code>    @FXML
      public TextField destination;
      @FXML
      public TextArea view;
      @FXML
      public TextArea point;
  
  
      public void initialize() {
          destination.appendText("LOL");
          view.appendText("LAA");
          point.appendText("LOWKAPF");
      }
  </code></pre>
  
  <p>As you can see, I'm appending text on all declared fields (FXML-ID'S ARE BOUND!) after the root has been loaded through the initialize method. Sounds good and great, but I get a NullPointerException.</p>
  
  <p>To point the things out clearly:
  - I've already bound the fxml-ids to their corresponding components.
  - The FXML file gets loaded up correctly (root is being loaded correctly, else the initialize method wouldnt work)</p>
  
  <p>This has nothing to do with the static access. Even without static access this does not work.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  
  &lt;AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="373.0" prefWidth="518.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="removed"&gt;
     &lt;children&gt;
        &lt;TextField fx:id="destination" layoutX="14.0" layoutY="19.0" prefHeight="25.0" prefWidth="464.0" promptText="Destination of the files" text="ie.: C:\" /&gt;
        &lt;Text layoutX="14.0" layoutY="57.0" strokeType="OUTSIDE" strokeWidth="0.0" text="moo" wrappingWidth="464.0" /&gt;
        &lt;TextArea fx:id="point" layoutX="14.0" layoutY="76.0" prefHeight="42.0" prefWidth="464.0" promptText="HI/&gt;
        &lt;Text layoutX="14.0" layoutY="131.0" strokeType="OUTSIDE" strokeWidth="0.0" text="meow" wrappingWidth="464.0" /&gt;
        &lt;TextArea fx:id="view" layoutX="14.0" layoutY="135.0" prefHeight="42.0" prefWidth="464.0" promptText="HI" /&gt;
        &lt;Text layoutX="14.0" layoutY="191.0" strokeType="OUTSIDE" strokeWidth="0.0" text="m00" wrappingWidth="464.0" /&gt;
        &lt;Button layoutX="220.0" layoutY="269.0" mnemonicParsing="false" onAction="#initialize" text="Default" /&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>Oh. Ok, so, What I did is was: </p>
  
  <pre><code>    package com.engine.application.content;
  
  import com.engine.Logger;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Settings extends Application {
  
      public static void start() {
          Application.launch();
      }
      @Override
      public void start(Stage primaryStage) throws Exception {
          Parent root = FXMLLoader.load(getClass().getResource(
                  "settings.fxml"));
          Scene scene = new Scene(root);
          setStageProperties(primaryStage, scene);
  
      }
  
      /**
       * Sets the properties of the application
       * 
       * @param stage
       *            the stage's properties to set
       * @param scene
       *            the scene's properties to set
       */
      private void setStageProperties(Stage stage, Scene scene) {
          stage.setScene(scene);
          stage.setTitle("Test");
          stage.centerOnScreen();
          stage.setResizable(true);
          stage.show();
          Logger.log("Launcher", "Set stage properties");
      }
  
  }
  </code></pre>
  
  <p>Then I'm calling<br>
  Application.start() 
  when a button is clicked</p>
  
  <p>This is the result:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Application launch must not be called more than once
      at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
      at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
      at javafx.application.Application.launch(Unknown Source)
      at xxx.Settings.start(Settings.java:14)
      at xxx.openMenu(ApplicationScene.java:43)
      ... 56 more
  </code></pre>
  
  <p>I'm not calling it somewhere else btw.</p>
  
  <p><strong>EDIT:</strong> 
  This is the Settings application init.</p>
  
  <pre><code>public class Settings extends Application {
  
  public static void main(String[] args) {
      launch(args);
  }
  @Override
  public void start(Stage primaryStage) throws Exception {
      Parent root = FXMLLoader.load(getClass().getResource(
              "settings.fxml"));
      Scene scene = new Scene(root);
      setStageProperties(primaryStage, scene);
      System.out.println("YAY");
  
  }
  
  /**
   * Sets the properties of the application
   * 
   * @param stage
   *            the stage's properties to set
   * @param scene
   *            the scene's properties to set
   */
  private void setStageProperties(Stage stage, Scene scene) {
      stage.setScene(scene);
      stage.setTitle("Test");
      stage.centerOnScreen();
      stage.setResizable(true);
      ApplicationScene.settingsMenu = stage;
      Logger.log("Launcher", "Set stage properties");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is the Main application
      public class ApplicationLauncher extends Application {</p>
  
  <pre><code>/**
   * The main method
   * 
   * @param args
   *            the arguments given upon start
   */
  public static void main(String args[]) {
      launch(args);
  }
  
  @Override
  public void start(Stage stage) throws Exception {
      Logger.log("Launcher", "Starting up..");
      Parent root = FXMLLoader.load(getClass().getResource(
              "ah.fxml"));
      Directory directory = new Directory();
  //  Logger.logError("LOL", "ERROR! LOLOLOL L /n LOL \n LOL LOL");
      Scene scene = new Scene(root);
      directory.createFolder();
      setStageProperties(stage, scene);
      Settings.main(null);
      Logger.log("Launcher", "Application started up!");
  }
  
  /**
   * Sets the properties of the application
   * 
   * @param stage
   *            the stage's properties to set
   * @param scene
   *            the scene's properties to set
   */
  private void setStageProperties(Stage stage, Scene scene) {
      stage.setScene(scene);
      stage.setTitle("Test");
      stage.centerOnScreen();
      stage.setResizable(true);
      stage.show();
      Logger.log("Launcher", "Set stage properties");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Result:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Application launch must not be called more than once
  </code></pre>
  
  <p>It's no where else called. (Btw. doing Settings.main(null); is the same as Settings.launch(); lol)</p>
  
  <p><strong>After re-thinking the concept</strong></p>
  
  <p>This did it:</p>
  
  <pre><code>new Settings().start(new Scene());
  </code></pre>