Trees

A WTree displays a tree widget.

Example
  • Furniture
    • Table
      • Cupboard
        • Chair
        • Coach
        source
          void Tree() {
            WContainerWidget container = new WContainerWidget();
            WTree tree = new WTree();
            container.addWidget(tree);
            tree.setSelectionMode(SelectionMode.Extended);
            WIconPair folderIcon =
                new WIconPair("icons/yellow-folder-closed.png", "icons/yellow-folder-open.png", false);
            WTreeNode node = new WTreeNode("Furniture", folderIcon);
            final WTreeNode furnitureNode = node;
            tree.setTreeRoot(node);
            tree.getTreeRoot().getLabel().setTextFormat(TextFormat.Plain);
            tree.getTreeRoot().setLoadPolicy(ContentLoading.NextLevel);
            tree.getTreeRoot().addChildNode(new WTreeNode("Table"));
            tree.getTreeRoot().addChildNode(new WTreeNode("Cupboard"));
            WTreeNode subtree = new WTreeNode("Chair");
            WTreeNode subtree_ = tree.getTreeRoot().addChildNode(subtree);
            tree.getTreeRoot().addChildNode(new WTreeNode("Coach"));
            tree.getTreeRoot().expand();
            subtree_.addChildNode(new WTreeNode("Doc"));
            subtree_.addChildNode(new WTreeNode("Grumpy"));
            subtree_.addChildNode(new WTreeNode("Happy"));
            subtree_.addChildNode(new WTreeNode("Sneezy"));
            subtree_.addChildNode(new WTreeNode("Dopey"));
            subtree_.addChildNode(new WTreeNode("Bashful"));
            subtree_.addChildNode(new WTreeNode("Sleepy"));
            WPushButton imageButton = new WPushButton("Use Image Icons");
            container.addWidget(imageButton);
            imageButton
                .clicked()
                .addListener(
                    this,
                    () -> {
                      WIconPair icon =
                          new WIconPair(
                              "icons/yellow-folder-closed.png", "icons/yellow-folder-open.png", false);
                      furnitureNode.setLabelIcon(icon);
                    });
            WPushButton FAButton = new WPushButton("Use Font-Awesome Icons");
            container.addWidget(FAButton);
            FAButton.clicked()
                .addListener(
                    this,
                    () -> {
                      WIconPair icon = new WIconPair("folder", "folder-open", false);
                      icon.setIconsType(WIconPair.IconType.IconName);
                      furnitureNode.setLabelIcon(icon);
                    });
          }
        

        Top