Using CheckBox

This is the most tricky cell factory. It provides a CheckBox for each ListView item, making it easy to create a todo list-style UI:

For such a list, we can't just use Strings, because we need to store the states of the checkboxes. Let's introduce a separate class for that:

    private static final class TodoItem {        final String name;        final BooleanProperty isDone = new SimpleBooleanProperty(false);        public TodoItem(String name) {            this.name = name;        }        @Override        public String toString() {            return name + (isDone.get() ? " DONE" : "");        }    }

Now, we can use CheckBoxListCell by providing a special callback, which will state the corresponding ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.