List of usage examples for javafx.scene.control TreeCell treeItemProperty
public final ReadOnlyObjectProperty<TreeItem<T>> treeItemProperty()
From source file:net.rptools.tokentool.controller.TokenTool_Controller.java
private void addPseudoClassToLeafs(TreeView<Path> tree) { PseudoClass leaf = PseudoClass.getPseudoClass("leaf"); tree.setCellFactory(tv -> {/*from w w w . jav a 2 s .c o m*/ TreeCell<Path> cell = new TreeCell<>(); cell.itemProperty().addListener((obs, oldValue, newValue) -> { if (newValue == null) { cell.setText(""); cell.setGraphic(null); } else { cell.setText(newValue.toFile().getName()); cell.setGraphic(cell.getTreeItem().getGraphic()); } }); cell.treeItemProperty().addListener((obs, oldTreeItem, newTreeItem) -> cell .pseudoClassStateChanged(leaf, newTreeItem != null && newTreeItem.isLeaf())); return cell; }); }