I have a ListView control in a JavaFX 2 modal dialog window.
This ListView displays DXAlias instances, the ListCells for which are manufactured by a cell factory. The m
For now, I am able to get the ListView to redraw and correctly indicate the selected default by using the following method, called forceListRefreshOn(), in my button handler:
@FXML
void handleAliasDefault(ActionEvent event) {
int sel = lsvAlias.getSelectionModel().getSelectedIndex();
if (sel >= 0 && sel < lsvAlias.getItems().size()) {
lsvAlias.setUserData(lsvAlias.getItems().get(sel));
this.forceListRefreshOn(lsvAlias);
}
}
The helper method just swaps out the ObservableList from the ListView and then swaps it back in, presumably forcing the ListView to update its ListCells:
private void forceListRefreshOn(ListView lsv) {
ObservableList items = lsv.getItems();
lsv.setItems(null);
lsv.setItems(items);
}