-
Bug
-
Resolution: Fixed
-
P3
-
8
-
jdk8 b115
The default comparator in TreeTableView is a Comparator<TreeItem<S>>, not a Comparator<S> as indicated by the signature of the getComparator method. This causes the code below to fail with a ClassCastException:
TreeTableView<Item> table = new TreeTableView<>(getRoot());
table.comparatorProperty().addListener((ObservableValue<? extends Comparator<Item>> observable, Comparator<Item> oldValue, Comparator<Item> newValue) ->
newValue.compare(new Item(0), new Item(1))
);
Workaround: getting rid of generics and explicitly casting to Comparator<TreeItem<Item>>.
TreeTableView<Item> table = new TreeTableView<>(getRoot());
table.comparatorProperty().addListener((ObservableValue<? extends Comparator<Item>> observable, Comparator<Item> oldValue, Comparator<Item> newValue) ->
newValue.compare(new Item(0), new Item(1))
);
Workaround: getting rid of generics and explicitly casting to Comparator<TreeItem<Item>>.