title: NullPointerException with Textfield in fxml
body: <p>I've got a problem with a NullPointerException.</p>
  
  <p>This is my Controller:</p>
  
  <pre><code>    public class Controller implements Initializable{
  
      public Label lbTitle;
      public Label lbAuthor;
      public Label lbChapters;
      public TextField tfTitle;
      public TextField tfAuthor;
      public TextArea taChapters;
      public ListView&lt;Book&gt; listView;
  
      private void OpenNewWindow(Book book1) throws Exception {
  
          String selected = listView.getSelectionModel().getSelectedItem().toString();
  
          FXMLLoader fxmlLoader = new FXMLLoader();
          fxmlLoader.setLocation(getClass().getResource("/zli/BooksFX/NewWindow.fxml"));
          Scene scene = new Scene(fxmlLoader.load(), 400, 400);
          Stage stage = new Stage();
  
          tfTitle.setText(book1.getTitle());
          tfAuthor.setText(book1.getAuthor());
          taChapters.setText(book1.toStringChapters());
  
          stage.setTitle(selected);
          stage.setScene(scene);
          stage.show();
      }
  
      @Override
      public void initialize(URL location, ResourceBundle resources) {
          Chapter chapter1Book1 = new Chapter(1, 100, "First Chapter...");
          Chapter chapter2Book1 = new Chapter(2, 400, "Second Chapter...");
          ArrayList&lt;Chapter&gt; book1Chapters = new ArrayList&lt;&gt;();
          book1Chapters.add(chapter1Book1);
          book1Chapters.add(chapter2Book1);
          Book book1 = new Book("IT: Not the one with the clown", "Stephen ITBerg", book1Chapters);
  
          Chapter chapter1Book2 = new Chapter(1, 100, "First Chapter...");
          Chapter chapter2Book2 = new Chapter(2, 400, "Second Chapter...");
          ArrayList&lt;Chapter&gt; book2Chapters = new ArrayList&lt;&gt;();
          book1Chapters.add(chapter1Book2);
          book1Chapters.add(chapter2Book2);
          Book book2 = new Book("Z Men", "Stan Lee", book2Chapters);
  
          Chapter chapter1Book3 = new Chapter(1, 100, "First Chapter...");
          Chapter chapter2Book3 = new Chapter(2, 400, "Second Chapter...");
          ArrayList&lt;Chapter&gt; book3Chapters = new ArrayList&lt;&gt;();
          book1Chapters.add(chapter1Book3);
          book1Chapters.add(chapter2Book3);
          Book book3 = new Book("Captain AlivePool", "Undead Zombie", book3Chapters);
  
          ObservableList&lt;Book&gt; items = FXCollections.observableArrayList (book1, book2, book3);
          listView.setItems(items);
          listView.setOnMouseClicked(e -&gt; {
              try {
                  OpenNewWindow(book1);
              } catch (Exception e1) {
                  e1.printStackTrace();
              }
          });
  
      }
  }
  </code></pre>
  
  <p>And this is my .fxml:</p>
  
  <pre><code>&lt;Pane prefHeight="400.0" prefWidth="400.0" style="-fx-background-color: #1ba77f;" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="zli.BooksFX.Controller"&gt;
      &lt;ListView fx:id="listView" disable="true" opacity="0.0" prefHeight="400.0" prefWidth="400.0" /&gt;
     &lt;Label fx:id="lbTitle" layoutX="8.0" layoutY="20.0" prefHeight="27.0" prefWidth="57.0" text="Title: " /&gt;
     &lt;Label fx:id="lbAuthor" layoutX="8.0" layoutY="90.0" text="Author: " /&gt;
     &lt;TextField text="ert" fx:id="tfTitle" editable="false" layoutX="72.0" layoutY="14.0" prefHeight="39.0" prefWidth="316.0" /&gt;
     &lt;TextField text="sdf" fx:id="tfAuthor" editable="false" layoutX="72.0" layoutY="84.0" prefHeight="39.0" prefWidth="316.0" /&gt;
     &lt;Label fx:id="lbChapters" layoutX="8.0" layoutY="160.0" text="Chapters: " /&gt;
     &lt;TextArea text="sdfs" fx:id="taChapters" editable="false" layoutX="7.0" layoutY="187.0" prefHeight="200.0" prefWidth="383.0" /&gt;
  &lt;/Pane&gt;
  </code></pre>
  
  <p>And this is the Error message:</p>
  
  <pre><code>java.lang.NullPointerException
      at zli.BooksFX.Controller.OpenNewWindow(Controller.java:37)
      at zli.BooksFX.Controller.lambda$initialize$0(Controller.java:73)
      at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
      at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
      at javafx.graphics/javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3589)
      at javafx.graphics/javafx.scene.Scene$ClickGenerator.access$8300(Scene.java:3517)
      at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3885)
      at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604)
      at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
      at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
      at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
      at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
      at java.base/java.lang.Thread.run(Thread.java:844)
  </code></pre>
  
  <p>Now, when I want to set the Text of my TextFields and TextAreas (tfTitle, tfAuthor, taChapters) to the assigned value, it gives me a "java.lang.NullPointerException" on the Line 37 in Controller, which is this:</p>
  
  <pre><code>tfTitle.setText(book1.getTitle());
  </code></pre>
  
  <p>And for your information: "Book" is a storage Class for Chapters.</p>
  
  <p>Because it was asked for, my other .fxml:</p>
  
  <pre><code>&lt;GridPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"
            fx:controller="zli.BooksFX.Controller"&gt;
  &lt;ListView fx:id="listView" prefWidth="400" /&gt;
  &lt;/GridPane&gt;
  </code></pre>