// Use a custom callback to determine the style of the tree item
layersTree.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
@Override
public TreeCell<String> call(TreeView<String> param) {
return new CheckBoxTreeCell<String>(){
@Override
public void updateItem(String item, boolean empty){
super.updateItem(item, empty);
// If there is no information for the Cell, make it empty
if(empty){
setGraphic(null);
setText(null);
// Otherwise if it's not representation as an item of the tree
// is not a CheckBoxTreeItem, remove the checkbox item
}else if (!(getTreeItem() instanceof CheckBoxTreeItem)){
setGraphic(null);
}
}
};
}
});