title: JavaFX FXML Controller initialize method not invoked
body: <p>I am trying to fill ListView from the content of a simple ArrayList. Here is my</p>
  
  <p>Controller.java file:</p>
  
  <pre><code>package design;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.ResourceBundle;
  
  import javafx.beans.property.ListProperty;
  import javafx.beans.property.SimpleListProperty;
  import javafx.collections.FXCollections;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.scene.control.Button;
  import javafx.scene.control.ListView;
  
  public class Controller {
  
      @FXML private Button buttontest;
      @FXML private ListView&lt;Song&gt; listViewofSongs;
  
      protected List&lt;Song&gt; songList = new ArrayList&lt;&gt;();
      protected ListProperty&lt;Song&gt; listProperty = new SimpleListProperty&lt;Song&gt;();
      Song Language = new Song("Peter", "myalbum", "yes", 2010);
  
      public void addSong(Song song){
          songList.add(song);
      }
  
      public void initialize(URL url, ResourceBundle rb) {
              addSong(Language);
              listViewofSongs.setItems(FXCollections.observableList(songList));
       }
  
  
  
  }
  </code></pre>
  
  <p>And here is my Style.fxml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.geometry.Insets?&gt;
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.control.ListView?&gt;
  &lt;?import javafx.scene.control.Separator?&gt;
  &lt;?import javafx.scene.control.TextField?&gt;
  &lt;?import javafx.scene.layout.ColumnConstraints?&gt;
  &lt;?import javafx.scene.layout.GridPane?&gt;
  &lt;?import javafx.scene.layout.Pane?&gt;
  &lt;?import javafx.scene.layout.RowConstraints?&gt;
  &lt;?import javafx.scene.text.Font?&gt;
  
  &lt;GridPane prefHeight="499.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="design.Controller"&gt;
     &lt;columnConstraints&gt;
        &lt;ColumnConstraints /&gt;
        &lt;ColumnConstraints /&gt;
        &lt;ColumnConstraints maxWidth="0.0" minWidth="0.0" prefWidth="0.0" /&gt;
        &lt;ColumnConstraints maxWidth="0.0" minWidth="0.0" prefWidth="0.0" /&gt;
     &lt;/columnConstraints&gt;
     &lt;rowConstraints&gt;
        &lt;RowConstraints /&gt;
        &lt;RowConstraints /&gt;
        &lt;RowConstraints maxHeight="0.0" minHeight="0.0" prefHeight="0.0" /&gt;
        &lt;RowConstraints maxHeight="10.0" minHeight="0.0" prefHeight="0.0" /&gt;
        &lt;RowConstraints maxHeight="10.0" minHeight="0.0" prefHeight="0.0" /&gt;
        &lt;RowConstraints fillHeight="false" maxHeight="500.0" minHeight="10.0" prefHeight="240.0" /&gt;
        &lt;RowConstraints fillHeight="false" maxHeight="500.0" minHeight="10.0" prefHeight="149.0" /&gt;
        &lt;RowConstraints fillHeight="false" maxHeight="500.0" minHeight="10.0" prefHeight="50.0" /&gt;
     &lt;/rowConstraints&gt;
     &lt;children&gt;
        &lt;Pane prefHeight="64.0" prefWidth="700.0"&gt;
           &lt;children&gt;
              &lt;Label layoutX="259.0" layoutY="14.0" text="Song Library"&gt;
                 &lt;font&gt;
                    &lt;Font name="Consolas Bold" size="26.0" /&gt;
                 &lt;/font&gt;
                 &lt;padding&gt;
                    &lt;Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /&gt;
                 &lt;/padding&gt;
              &lt;/Label&gt;
           &lt;/children&gt;
        &lt;/Pane&gt;
        &lt;Separator prefWidth="200.0" GridPane.rowIndex="4" /&gt;
        &lt;ListView fx:id="listViewofSongs" editable="true" prefHeight="239.0" prefWidth="700.0" GridPane.rowIndex="5" /&gt;
  
        &lt;Label text="Song Info" GridPane.halignment="CENTER" GridPane.rowIndex="6" GridPane.valignment="TOP"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="10.0" /&gt;
           &lt;/GridPane.margin&gt;
           &lt;font&gt;
              &lt;Font name="Consolas" size="22.0" /&gt;
           &lt;/font&gt;
           &lt;padding&gt;
              &lt;Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /&gt;
           &lt;/padding&gt;
        &lt;/Label&gt;
        &lt;Label GridPane.rowIndex="6" /&gt;
        &lt;Label text="NAME" GridPane.rowIndex="6"&gt;
           &lt;font&gt;
              &lt;Font name="Calibri" size="19.0" /&gt;
           &lt;/font&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="60.0" left="200.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/Label&gt;
        &lt;TextField maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="343.0" GridPane.rowIndex="6"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="60.0" left="275.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/TextField&gt;
        &lt;Label text="ARTIST" GridPane.rowIndex="6"&gt;
           &lt;font&gt;
              &lt;Font name="Calibri" size="19.0" /&gt;
           &lt;/font&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets left="200.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/Label&gt;
        &lt;TextField maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="343.0" GridPane.rowIndex="6"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets left="275.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/TextField&gt;
        &lt;Label text="ALBUM" GridPane.rowIndex="6"&gt;
           &lt;font&gt;
              &lt;Font name="Calibri" size="19.0" /&gt;
           &lt;/font&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="-60.0" left="200.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/Label&gt;
        &lt;TextField maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="343.0" GridPane.rowIndex="6"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="-60.0" left="275.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/TextField&gt;
        &lt;Label text="YEAR" GridPane.rowIndex="6"&gt;
           &lt;font&gt;
              &lt;Font name="Calibri" size="19.0" /&gt;
           &lt;/font&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="-120.0" left="200.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/Label&gt;
        &lt;TextField maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="25.0" prefWidth="343.0" GridPane.rowIndex="6"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets bottom="-120.0" left="275.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/TextField&gt;
        &lt;Button mnemonicParsing="false" prefHeight="28.0" prefWidth="75.0" text="ADD" GridPane.rowIndex="7"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets left="125.0" /&gt;
           &lt;/GridPane.margin&gt;
           &lt;font&gt;
              &lt;Font name="Corbel" size="15.0" /&gt;
           &lt;/font&gt;
        &lt;/Button&gt;
        &lt;Button mnemonicParsing="false" prefHeight="28.0" prefWidth="75.0" text="EDIT" GridPane.rowIndex="7"&gt;
           &lt;font&gt;
              &lt;Font name="Corbel" size="15.0" /&gt;
           &lt;/font&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets left="325.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/Button&gt;
        &lt;Button mnemonicParsing="false" prefHeight="28.0" prefWidth="75.0" text="DELETE" GridPane.rowIndex="7"&gt;
           &lt;font&gt;
              &lt;Font name="Corbel" size="15.0" /&gt;
           &lt;/font&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets left="525.0" /&gt;
           &lt;/GridPane.margin&gt;
        &lt;/Button&gt;
        &lt;Separator orientation="VERTICAL" prefHeight="200.0" GridPane.rowIndex="7"&gt;
           &lt;GridPane.margin&gt;
              &lt;Insets left="250.0" /&gt;
           &lt;/GridPane.margin&gt;
           &lt;padding&gt;
              &lt;Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /&gt;
           &lt;/padding&gt;
        &lt;/Separator&gt;
     &lt;/children&gt;
  &lt;/GridPane&gt;
  </code></pre>
  
  <p>The program runs, but the song I have entered does not appear in the ListView (and the Song class does have a toString method).</p>
  
  <p>What can I do? </p>