How can I bind a TableView
items to a running service value like in a ListView
:
todoList.itemsProperty().bind(service.valueProperty());
When I tried I get a compile-time error:
error: method bind in interface Property<T> cannot be applied to given types:
required : ObservableValue<? extends ObservableList<TodoTAsk>>
found : ReadOnlyObjectProperty<List<TodoTask>>
Edit: My service class
public final class AllTasks extends Service<ObservableList<TodoTask>> {
@Override
protected Task<ObservableList<TodoTask>> createTask() {
return new Task<ObservableList<TodoTask>>() {
@Override
protected ObservableList<TodoTask> call() throws Exception {
ObservableList<TodoTask> list = FXCollections.observableArrayList();
// list.addAll(new TaskRepository().getAllTasks());
for (TodoTask task : new TaskRepository().getAllTasks()) {
Thread.sleep(1500);
list.add(task);
}
System.out.println(list);
return list;
}
};
}
}