Search in sources :

Example 1 with JFXTreeView

use of com.jfoenix.controls.JFXTreeView in project JFoenix by jfoenixadmin.

the class TreeViewDemo method start.

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);
    JFXTreeView<String> treeView = new JFXTreeView<>(rootNode);
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem<String> depNode = new //,new ImageView(depIcon)   // Set picture
            TreeItem<>(//,new ImageView(depIcon)   // Set picture
            employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }
    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);
    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}
Also used : TreeItem(javafx.scene.control.TreeItem) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) JFXTreeView(com.jfoenix.controls.JFXTreeView)

Aggregations

JFXTreeView (com.jfoenix.controls.JFXTreeView)1 Scene (javafx.scene.Scene)1 TreeItem (javafx.scene.control.TreeItem)1 VBox (javafx.scene.layout.VBox)1