title: javafx listview shows too many items
body: <p>I have a ListView in JavaFX and when I'm deleting a item there will show up more items in the ListView but not in the list.</p>
  
  <p>Declaration of ObservableList and Extractor</p>
  
  <pre><code>Callback&lt;ElectricDeviceType, Observable[]&gt; deviceTypeExtractor = new Callback&lt;ElectricDeviceType, Observable[]&gt;() {
      @Override
      public Observable[] call(ElectricDeviceType t) {
          return new Observable[] { t.maxValue, t.name, t.getDevices() };
      }
  };
  ObservableList&lt;ElectricDeviceType&gt; deviceTypes = FXCollections
          .observableArrayList(deviceTypeExtractor);    
  </code></pre>
  
  <p>Here I'm setting the Devices to the ListView</p>
  
  <pre><code>    public void setElectricDevices(ElectricDeviceType... list) {
      deviceTypes.addAll(list);
      deviceTypeList.setItems(deviceTypes);
      deviceTypeList
              .setCellFactory(new Callback&lt;ListView&lt;ElectricDeviceType&gt;, javafx.scene.control.ListCell&lt;ElectricDeviceType&gt;&gt;() {
                  @Override
                  public ListCell&lt;ElectricDeviceType&gt; call(
                          ListView&lt;ElectricDeviceType&gt; listView) {
                      return new ElectricDeviceTypeListViewCell(_this,
                              simulation);
                  }
              });
  }
  </code></pre>
  
  <p>Class ElectricDeviceTypeListViewCell</p>
  
  <pre><code>public class ElectricDeviceTypeListViewCell extends ListCell&lt;ElectricDeviceType&gt; {
  private MainWindowController controller;
  private Simulation simulation;
  
  public ElectricDeviceTypeListViewCell(MainWindowController c, Simulation s) {
      controller = c;
      simulation = s;
  }
  
  @Override
  public void updateItem(ElectricDeviceType t, boolean empty) {
      super.updateItem(t, empty);
      if (t != null) {
          ElectricDeviceTypeController data = new ElectricDeviceTypeController(controller, simulation);
          data.setInfo(t);
          setGraphic(data.getBox());
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I delete one item from my observable list, my listview shows 5 items instead of 2. But my observable only has 2 items inside. If I delete all of my items then i the duplicates are deleted too.</p>
  
  <p><a href="http://imgur.com/3De1EhL,BshWQVI" rel="nofollow">Before delete</a></p>
  
  <p><a href="http://imgur.com/3De1EhL,BshWQVI#1" rel="nofollow">After delete</a></p>
  
  <p>Could you please help me with that?</p>