Example usage for javafx.scene.control TreeCell treeItemProperty

List of usage examples for javafx.scene.control TreeCell treeItemProperty

Introduction

In this page you can find the example usage for javafx.scene.control TreeCell treeItemProperty.

Prototype

public final ReadOnlyObjectProperty<TreeItem<T>> treeItemProperty() 

Source Link

Document

Each TreeCell represents at most a single TreeItem , which is represented by this property.

Usage

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;
    });
}