That looks like a bug, probably in the behavior class for ListView
. You should file a bug report at https://javafx-jira.kenai.com
Note that
ObservableList<String> names = FXCollections.observableArrayList();
names.addListener((ListChangeListener.Change<? extends String> c) -> {
while (c.next()) {
System.out.printf("from %d, to %d, removed %d, added %d\n",
c.getFrom(), c.getTo(), c.getRemovedSize(), c.getAddedSize());
if (c.wasAdded()) System.out.println("was added");
if (c.wasRemoved()) System.out.println("was removed");
if (c.wasPermutated()) System.out.println("was permutated");
if (c.wasUpdated()) System.out.println("was updated");
if (c.wasReplaced()) System.out.println("was replaced");
System.out.println("removed:");
for (String e : c.getRemoved()) {
System.out.println(" " + e);
}
System.out.println("added:");
for (String e : c.getAddedSubList()) {
System.out.println(" " + e);
}
System.out.println("selected:");
for (String e : names) {
System.out.println(" " + e);
}
System.out.println();
}
});
names.add("Julia");
names.add("Ian");
names.add("Sue");
behaves as you would expect.