title: JavaFX - How disable CheckboxListCell in ListView?
body: <p>I have no idea how can I make disable checkboxes in checklistview.
  <code>CheckListView</code> is from the <strong>controlsfx</strong>. I am newbie.</p>
  
  <p>Task object, which has to be wrapped into a checkbox list cell.</p>
  
  <pre><code>  public class Task {
  
  
  
    private final ReadOnlyStringWrapper name;
  
    private final ReadOnlyIntegerWrapper blockId;
  
    private final SimpleBooleanProperty isSelected;
  
  
    private final boolean isFound;
  
    public Task(String name, boolean isSelected, int blockId) {
      this.name = new ReadOnlyStringWrapper(name);
      this.isSelected = new SimpleBooleanProperty(isSelected);
      this.blockId = new ReadOnlyIntegerWrapper(blockId);
      this.isFound = isSelected;
    }
  
    public boolean isSelected() {
      return isSelected.get();
    }
  
    public void setSelected(boolean selected) {
      this.isSelected.set(selected);
    }
  
    public SimpleBooleanProperty selectedProperty() {
      return isSelected;
    }
  
    public String getName() {
      return name.get();
    }
  
    public ReadOnlyStringProperty nameProperty() {
      return name.getReadOnlyProperty();
    }
  
    public int getBlockId() {
      return blockId.get();
    }
  
    public ReadOnlyIntegerProperty blockIdProperty() {
      return blockId.getReadOnlyProperty();
    }
  
    @Override
    public String toString() {
      return getName();
    }
  
    public boolean isFound() {
      return isFound;
    }
  </code></pre>
  
  <p>ListView</p>
  
  <pre><code>  List&lt;Task&gt; tasksOfSection = domainModel.getTasks();
    final ObservableList&lt;Task&gt; tasks = FXCollections.observableArrayList(tasksOfSection);
    final CheckListView&lt;Task&gt; checkListView = new CheckListView&lt;&gt;(tasks);
  
    Callback&lt;ListView&lt;Task&gt;, ListCell&lt;Task&gt;&gt; wrappedCellFactory = checkListView.getCellFactory();
  
    checkListView.setCellFactory(listView -&gt; {
        CheckBoxListCell&lt;Task&gt; cell =  new CheckBoxListCell&lt;&gt;();
  
        if (wrappedCellFactory != null) {
          cell = (CheckBoxListCell&lt;Task&gt;) wrappedCellFactory.call(listView);            
        }
        cell.setSelectedStateCallback((Task item) -&gt; item.selectedProperty());
  
        // This throw null pointer exception.
        cell.setDisable(!cell.getItem().isFound());
  
        cell.itemProperty().addListener(new ChangeListener&lt;Task&gt;(){
          @Override
          public void changed(ObservableValue&lt;? extends Task&gt; observable, Task oldValue, Task newValue) {             
            // I cannot modify here the checkbox cell...           
          }
  
        });
  
        return cell;
      }
    );
  </code></pre>
  
  <p>So I call the <code>cell.setDisable()</code> method on the <code>CheckboxListCell</code>, but I have a problem, the cell's item (a task object) always null, when I call it with the <code>getItem()</code> method.</p>
  
  <p>Yes, I have tried to override the <code>updateItem</code> function(), but when I scrolling in the listview, then the checkboxes were setted to disable, the <code>updateItem</code> is listen every event, I think this. So this was useless. 
  I want to disable the checkbox which <code>isFound's</code> value false, because I want to prevent that the User click on it. But the user should see the full list.</p>
  
  <p>What do you think, what can I do?</p>
  
  <p>Thanks for the help.</p>