title: JavaFX ListChangedListeners not firing with ControlsFX PopOver and CheckListView
body: <p>I am writing a generic Java class to display a list of filter items that can be un/checked and the resulting selection being then passed to a controller to filter the collection of primary objects for display. I'm using two ControlsFX controls: the <code>PopOver</code> to contain the filter list and a <code>CheckListView</code> to display and control the individual items.</p>
  
  <p>The flow is that the filter <code>PopOver</code> class is instantiated in the controller's constructor and the source data is reloaded every time it is shown.</p>
  
  <p>On the surface the code appears to work. The source items are added, the checking and unchecking works and the number of items in the list of checked items is correct. However I've added listeners to the Observable Lists for both the source data and the list of checked items and neither is fired.</p>
  
  <p>I've tried writing the listeners in-line and as separate methods (as in the example) and I've tried writing them in traditional <code>onChanged</code> and lambda styles. Neither made a difference.
  I've also tried using almost identical code just using the<code>CheckListView</code> as a node of a pane. This did work exactly as expected.</p>
  
  <p>I've also gone through the ControlsFX issues log and found nothing directly relevant (except to confirm that the code I was using seemed OK).</p>
  
  <p>This is the Filter class:</p>
  
  <pre><code>package debuglogger;
  
  import javafx.collections.FXCollections;
  import javafx.collections.ListChangeListener;
  import javafx.collections.ObservableList;
  import javafx.scene.layout.BorderPane;
  import org.controlsfx.control.CheckListView;
  import org.controlsfx.control.PopOver;
  
  public class FilterPopOverSO&lt;T&gt; extends PopOver {
  
  private ObservableList&lt;T&gt; sourceData;
  
  private BorderPane popoverNode;
  
  private CheckListView&lt;T&gt; filterList;
  
  /**
   * ============================================================================================
   * Constructor
   * ============================================================================================
   */
  
  public FilterPopOverSO() {
  
      super();
  
      sourceData = FXCollections.observableArrayList();
  
      popoverNode = new BorderPane();
  
      filterList = new CheckListView&lt;&gt;();
      filterList.setPrefWidth(600D);
      filterList.setMaxWidth(600D);
  
      popoverNode.setCenter(filterList);
      setContentNode(popoverNode);
  
      filterList.getItems().addListener(sourceItemsListener);
  
      filterList.getCheckModel().getCheckedItems().addListener(checkedItemsListener);
  
      filterList.getCheckModel().checkAll();
  }
  
  /**
   * ============================================================================================
   * Listeners
   * ============================================================================================
   */
  
  ListChangeListener&lt;T&gt; sourceItemsListener = (change) -&gt; {
  
      System.out.println("Start of Change Listener 'sourceItemsListener'");
  
      while(change.next()) {
  
          System.out.println("     Added:      " + change.wasAdded());
          System.out.println("     Permutated: " + change.wasPermutated());
          System.out.println("     Removed:    " + change.wasRemoved());
          System.out.println("     Updated:    " + change.wasUpdated());
  
      }
  
      System.out.println("End of  of Change Listener 'sourceItemsListener'");
  };
  
  ListChangeListener&lt;T&gt; checkedItemsListener = (change) -&gt; {
  
      System.out.println("Start of Change Listener 'checkedItemsListener'");
  
      while(change.next()) {
  
          System.out.println("     Added:      " + change.wasAdded());
          System.out.println("     Permutated: " + change.wasPermutated());
          System.out.println("     Removed:    " + change.wasRemoved());
          System.out.println("     Updated:    " + change.wasUpdated());
  
      }
  
      System.out.println("End of  of Change Listener 'checkedItemsListener'");
  };
  
  public void setSourceData(ObservableList&lt;T&gt; sourceData) {
      filterList.setItems(sourceData);
  }
  }
  </code></pre>
  
  <p>And this is the test stub:</p>
  
  <pre><code>package scratchpad;
  
  import debuglogger.FilterPopOverSO;
  import javafx.application.Application;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.AnchorPane;
  import javafx.stage.Stage;
  
  public class FilterPopOverTest extends Application {
  
  @Override
  public void start(Stage primaryStage) {
  
      ObservableList&lt;String&gt; sourceList = FXCollections.observableArrayList("Item 1", "Item 2", "Item 3");
      FilterPopOverSO&lt;String&gt; p = new FilterPopOverSO&lt;&gt;();        
  
      AnchorPane root = new AnchorPane();
  
      Button btn = new Button("Click Me!");
  
      btn.setOnAction(event -&gt; {
  
          System.out.println("Just to show that I was here!");
          p.setSourceData(sourceList);
          p.show(btn);
  
      });
  
      root.getChildren().add(btn);
      AnchorPane.setTopAnchor(btn, 50D);
      AnchorPane.setLeftAnchor(btn, 50D);
  
      primaryStage.setTitle("Filter PopOver Test");
      primaryStage.setScene(new Scene(root, 500, 500));
      primaryStage.show();
  }
  
  public static void main(String[] args) {
      launch(args);
  }
  }
  </code></pre>