-
Enhancement
-
Resolution: Unresolved
-
P4
-
8u20
-
Windows 7 64bit, JDK 8u20 Build b23 64bit
If the sorting of a SortedList depends on other data then the source list there is no nice way to sort the SortedList again if the other data has been changed.
A (not very nice) workaround is to set a new Comparator for the SortedList every time the other data has been changed:
IntegerProperty counter = new SimpleIntegerProperty();
SortedList<String> sortedList = new SortedList<>(mySourceList);
sortedList.setComparator(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int result = 0;
// Compare based on counter
return result;
}
});
myListView.setItems(sortedList.sorted());
counter.addListener(o -> sortedList.setComparator(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int result = 0;
// Compare based on counter
return result;
}
}));
A (not very nice) workaround is to set a new Comparator for the SortedList every time the other data has been changed:
IntegerProperty counter = new SimpleIntegerProperty();
SortedList<String> sortedList = new SortedList<>(mySourceList);
sortedList.setComparator(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int result = 0;
// Compare based on counter
return result;
}
});
myListView.setItems(sortedList.sorted());
counter.addListener(o -> sortedList.setComparator(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int result = 0;
// Compare based on counter
return result;
}
}));