title: JavaFx NullPointer Exception when populating a ListView
body: <p>I have only been working with JavaFX for the past day but seem to be experiencing a null pointer exception when trying to populate a list view.</p>
  
  <p>Basically I have login form and when the user logs in a new .fxml form is loaded which contains an accordion with a list view inside.</p>
  
  <p>I would like the list view to populate once the user clicks the login button. debugging show that AccountMenu is null, however I cannot figure out why. Can anyone point me in the right direction?</p>
  
  <p>Thanks</p>
  
  <pre><code>public class Controller {
      @FXML
      ListView&lt;String&gt; AccountMenu;
  
  
   void Login(ActionEvent event) {
     try {
              ObservableList&lt;String&gt; items =FXCollections.observableArrayList (
                      "Item one","Item two");
              AccountMenu.setItems(items);
  
          }catch(Exception e){
              e.printStackTrace();
          }
  }
  </code></pre>
  
  <p>Part of the fxml file:</p>
  
  <pre><code>&lt;Accordion layoutY="136.0" prefHeight="768.0" prefWidth="210.0"&gt;
      &lt;panes&gt;
          &lt;TitledPane id="MyAccount" animated="false" text="My account"&gt;
            &lt;content&gt;
              &lt;AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"&gt;
                   &lt;children&gt;
                      &lt;ListView id="AccountMenu" fx:id="AccountMenu" layoutX="-1.0" prefHeight="658.0" prefWidth="210.0" /&gt;
                   &lt;/children&gt;
                &lt;/AnchorPane&gt;
            &lt;/content&gt;
          &lt;/TitledPane&gt;
        &lt;TitledPane animated="false" style="-fx-background-color: red;" text="Books"&gt;
  </code></pre>