import com.sun.javafx.runtime.VersionInfo; import javafx.application.Application; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ObservableValue; import javafx.scene.Scene; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.control.cell.CheckBoxTreeCell; import javafx.scene.layout.StackPane; import javafx.stage.Stage; import javafx.util.Callback; import javafx.util.StringConverter; import java.util.ArrayList; import java.util.List; public class CheckBoxList extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { stage.setTitle(VersionInfo.getRuntimeVersion()); stage.setScene(getScene()); stage.show(); } private Scene getScene() { List> ls = new ArrayList>(10); for (int i = 0; i < 10; i++) { ls.add(new TreeItem(new Data("Test " + i))); } TreeView tv = new TreeView(); tv.setRoot(new TreeItem(new Data("Root"))); tv.getRoot().getChildren().addAll(ls); tv.getRoot().setExpanded(true); tv.setEditable(true); tv.setCellFactory(CheckBoxTreeCell.forTreeView(new Callback, ObservableValue>() { @Override public ObservableValue call(TreeItem param) { return param.getValue().predicate; } }, new StringConverter>() { @Override public String toString(TreeItem object) { return object.getValue().getValue(); } @Override public TreeItem fromString(String string) { return new TreeItem(new Data(string)); } } )); StackPane root = new StackPane(); root.getChildren().add(tv); return new Scene(root, 600, 400); } public static class Data { private String value; public SimpleBooleanProperty predicate; public Data(String value) { this.value = value; predicate = new SimpleBooleanProperty(false); } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public boolean getPredicate() { return predicate.get(); } public void setPredicate(boolean val) { predicate.set(val); } } }