title: Ghost items in javafx ListView with custom ListCell
body: <p>I try to view a custom object in a ListView using a custom ListCell. As an example to demonstrate the problem I chose <code>java.util.File</code>. Also for demonstration purpose I disable the ListCell directly when rendered. The items are added by an external process simulated by the thread. Everything looks nice until I apply the CSS coloring the disabled ListCell. Now it seems that there are some ghost items which get disabled together with the ListCell they are created of.</p>
  
  <p>How can I solve this?</p>
  
  <blockquote>
    <p>App.java</p>
  </blockquote>
  
  <pre><code>public class App extends Application
  {
      @Override
      public void start( Stage primaryStage )
      {   
          final ListView&lt;File&gt; listView = new ListView&lt;&gt;();
          listView.setCellFactory( column -&gt; { 
              return new ListCell&lt;File&gt;()
              {
                  protected void updateItem( File item, boolean empty )
                  {   
                      super.updateItem( item, empty );
  
                      if( item == null || empty )
                      {
                          setGraphic( null );
                          return;
                      }
  
                      setDisable( true );                 
                      setGraphic( new TextField( item.getName() ) );
                  }
              };
          });
  
          new Thread( () -&gt; {
              for( int i=0 ; i&lt;10 ; ++i )
              {
                  try
                  {
                      Thread.sleep( 1000 );
                  }
                  catch( Exception e )
                  {
                      e.printStackTrace();
                  }
                  final int n = i;
                  Platform.runLater( () -&gt; {
                      listView.getItems().add( new File( Character.toString( (char)( (int) 'a' + n ) ) ) );
                  });
              }       
          }).start();
  
          Scene scene = new Scene( listView );    
          scene.getStylesheets().add( "app.css" );
  
          primaryStage.setScene( scene );
          primaryStage.show();
      }
  
      @Override
      public void stop() throws Exception
      {
          super.stop();
      }
  
      public static void main( String[] args ) throws Exception
      {       
          launch( args );     
      }
  }
  </code></pre>
  
  <blockquote>
    <p>app.css</p>
  </blockquote>
  
  <pre><code>.list-cell:disabled {
      -fx-background-color: #ddd;
  }
  </code></pre>