title: Java TextArea setText() and appendText() returning Null Pointer Exception
body: <p>I am using JavaFX 8 and FXML in this project and trying to update my text area with the results from other classes within the program.</p>
  
  <p>The Text Area is defined in the FXML document as such:</p>
  
  <pre><code>&lt;TextArea fx:id="feedBack" editable="false" focusTraversable="false"
  layoutX="203.0" layoutY="32.0" prefHeight="205.0" prefWidth="308.0"
  wrapText="true"/&gt;
  </code></pre>
  
  <p>It is called in the controller here, note that originally it was a "private" item but to make it work with the classes I made it public:</p>
  
  <pre><code>@FXML
  public static TextArea feedBack;
  </code></pre>
  
  <p>EDIT: It is worth noting that when the TextArea is identified as "private" I have no issue getting the set/append text method to work but this does not allow me to use the text area in other classes, which is what I need to do.</p>
  
  <p>However now when I try to do either appendText() or setText(), such as follows:</p>
  
  <pre><code>feedBack.setText("Connection Made"); 
  </code></pre>
  
  <p>I am given a null point exception. Why is this? I have made this work in JavaFX 7 with FXML by doing the same thing and it works fine. What am I missing to make this work?</p>
  
  <hr>
  
  <p>EDIT, test/proof of brokenness with complete tiny program.
  I did not make another class for this one as the textarea won't work in the control anyway.</p>
  
  <p>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="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="textareatester.FXMLDocumentController"&gt;
  &lt;children&gt;
  &lt;Label fx:id="label" layoutX="126" layoutY="120" minHeight="16" minWidth="69" /&gt;
  &lt;TextArea fx:id="feedback" layoutX="61.0" prefHeight="200.0" prefWidth="200.0" wrapText="true" /&gt;
    &lt;Button fx:id="dostuff" layoutX="261.0" layoutY="62.0" mnemonicParsing="false" onAction="#handleButtonAction" text="Button" /&gt;
  &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>Main Method:</p>
  
  <pre><code>package textareatester;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class TextAreaTester 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();
  }
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      launch(args);
  }
  }
  </code></pre>
  
  <p>Controller Class:</p>
  
  <pre><code>package textareatester;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.TextArea;
  
  public class FXMLDocumentController implements Initializable {
  
  @FXML
  private Label label;
  @FXML
  public static TextArea feedback;
  @FXML
  private Button dostuff;
  
  @FXML
  private void handleButtonAction(ActionEvent event) {
      System.out.println("You clicked me!");
     feedback.setText("Hello World!"); ///&lt;-- this is what gives me the NPE
  }
  
  @Override
  public void initialize(URL url, ResourceBundle rb) {
      // not touching anything
  }    
  }
  </code></pre>
  
  <p><strong>Solution for those who are curious:</strong>
  I ended up simply returning my results strings from my methods and then appending them to the TextArea. </p>