Bug when combining ListView and SortedList?

Fisher, Robert robert.fisher.ext at zeiss.com
Fri Oct 30 13:38:57 UTC 2015


Done.

From: Scott Palmer [mailto:swpalmer at gmail.com]
Sent: Freitag, 30. Oktober 2015 14:38
To: Fisher, Robert
Cc: openjfx-dev at openjdk.java.net
Subject: Re: Bug when combining ListView and SortedList?

That looks like a bug to me.  Please report it.

On Fri, Oct 30, 2015 at 7:07 AM, Fisher, Robert <robert.fisher.ext at zeiss.com<mailto:robert.fisher.ext at zeiss.com>> wrote:
Hi,

I am wondering if this behaviour of ListView's MultipleSelectionModel is correct:


ListView<String> listView = new ListView<>();
ObservableList<String> items = FXCollections.observableArrayList();
SortedList<String> sortedItems = new SortedList<>(items);
sortedItems.setComparator(String::compareTo);
listView.setItems(sortedItems);

items.add("2");
listView.getSelectionModel().selectFirst();
items.addAll("1", "3");

System.out.println(listView.getSelectionModel().getSelectedItem());
System.out.println(listView.getSelectionModel().getSelectedItems());

This yields the following console output on JDK 8u66:

2
[1]

The "selected item" and "selected items" are out of sync. Interestingly if you attach a ListChangeListener to the selected items list, it only fires once (when selectFirst is called).

Is this a bug?

Cheers,
Rob



More information about the openjfx-dev mailing list