I want to add keys(Branch) of ObservableHashmap in column of TableView. So I created TableView with HashMap like that:
ObservableMap<Branch, Boolean> myMap = FXCollections.observableHashMap();
ObservableList<Branch> lst = FXCollections.observableArrayList(myMap.keySet());
this.chosenBranTable.setItems(lst);
... and defined CellValueFactory in this way:
this.chosenBranColumn.setCellValueFactory((CellDataFeatures<Branch, String> listItem) ->
{
return new ReadOnlyObjectWrapper<String>(listItem.getValue().toString());
});
The problem is that - when I have changed myMap there is no changes in the TableView. But if I executed:
ObservableList<Branch> lst = FXCollections.observableArrayList(myMap.keySet());
this.chosenBranTable.setItems(lst);
after changing of myMap then changes in the TableView appeared. Before ObservableHashMap I used ObservableList and there was no problem with updating.