Example usage for javafx.scene.control CheckBoxTreeItem CheckBoxTreeItem

List of usage examples for javafx.scene.control CheckBoxTreeItem CheckBoxTreeItem

Introduction

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

Prototype

public CheckBoxTreeItem(T value, Node graphic) 

Source Link

Document

Creates a CheckBoxTreeItem with the value property set to the provided object, and the graphic set to the provided Node.

Usage

From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignView.java

private void addTreeView() {
    // Root node (my computer)
    CheckBoxTreeItem<String> rootNode = new CheckBoxTreeItem<>(getHostName(),
            new ImageView(new Image("images/computer.png")));
    checkTreeView = new CheckTreeView<>(rootNode);
    rootNode.addEventHandler(TreeItem.<Object>branchExpandedEvent(), new ExpandEventHandler(checkTreeView));
    rootNode.addEventHandler(TreeItem.<Object>branchCollapsedEvent(), new CollapseEventHandler());

    // Root items
    Iterable<Path> rootDirectories = FileSystems.getDefault().getRootDirectories();
    for (Path name : rootDirectories) {
        if (Files.isDirectory(name)) {
            FilePathTreeItem treeNode = new FilePathTreeItem(name);
            rootNode.getChildren().add(treeNode);
        }/*from  w  w w .ja  v  a 2  s  . c om*/
    }
    rootNode.setExpanded(true);

    // Add data and add to gui
    treeViewHBox.getChildren().clear();
    treeViewHBox.getChildren().add(checkTreeView);
    HBox.setHgrow(checkTreeView, Priority.ALWAYS);
}