1

I have some method for work with the TableView.

private void setClusterSelectionHelp() {
    List<Cluster> clusters = tableCluster.getSelectionModel().getSelectedItems();
    int clusterCount = clusters.size();

    for (int i = 0; i < clusterCount; i++) {
        System.out.println(clusters.get(i).toString());
        System.out.println(clusters.get(i).toString());
    }

}

This method is called from selection change listener.

tableCluster.getSelectionModel().selectedItemProperty().addListener((obs,
            oldSelection, newSelection) -> {
    setClusterSelectionHelp();
});

The code of method is replaced by some abstraction for better understanding.

In most cases, both "println" output the string of object. But sometimes the first line displays "null". This "sometimes" I can't describe, because it happens randomly.

Can someone explain what is this black magic ?

gearquicker
  • 571
  • 4
  • 18
  • I think it's the same bug that's described here: http://stackoverflow.com/questions/36353518/javafx-table-view-multiple-selection-sometimes-skips-one-of-the-items/38207246#38207246 Try working with `getSelectedIndices` instead of `getSelectedItems`, or wait until 8u112 is released. – Itai Sep 05 '16 at 04:58
  • When I replaced getSelectedItems on getSelectedIndices, on output I got just "-1" instead "null" – gearquicker Sep 05 '16 at 05:23
  • I was under the impression `getSelectedIndices` wasn't affected, but maybe it is? In that case, assuming it is the same bug, I think your only option is to wait until 8u112 is out (should be out by 10/2016, but you never know with Java). – Itai Sep 05 '16 at 05:26
  • It seems that way.. Thank you very much. – gearquicker Sep 05 '16 at 05:36

0 Answers0