1

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;
        }
     }; 
   }
}
4

1 回答 1

2

你是如何定义你的服务的?

尝试类似:

public class MyService extends Service<ObservableList<TodoTAsk>>
于 2013-06-07T09:56:18.647 回答