Roughian Examples Site Map - GWT Examples - Tutorials

Tree


Version 1.0 onwards

The TreeItem widget is a branch for a Tree widget



Listeners


None


Notes


TreeItems are the branches of the tree and can't exist by themselves in the UI - they can only exist in the UI if attached to a Tree. Once you get to the end of the branches

The Tree itself is just a container for TreeItems. It is just the seed from which the branches grow, whereas the TreeItem is a branch. Both Trees and TreeItems can have multiple sub-branches.

Branches contain other branches, other widgets, or a mixture of both. You can programmatically open or close TreeItems and you can select them, but that is all the interesting stuff it does.

To capture when a TreeItem is opened, closed or selected, add a TreeListener to the Tree


Code


class Demo extends Composite
{
    public Demo()
    {
        Tree tree = new Tree();
        initWidget(tree);
        TreeItem outerRoot = new TreeItem("Item 1");
        outerRoot.addItem("Item 1-1");
        outerRoot.addItem("Item 1-2");
        outerRoot.addItem("Item 1-3");
        outerRoot.addItem(new CheckBox("Item 1-4"));
        tree.addItem(outerRoot);

        TreeItem innerRoot = new TreeItem("Item 1-5");
        innerRoot.addItem("Item 1-5-1");
        innerRoot.addItem("Item 1-5-2");
        innerRoot.addItem("Item 1-5-3");
        innerRoot.addItem("Item 1-5-4");
        innerRoot.addItem(new CheckBox("Item 1-5-5"));

        outerRoot.addItem(innerRoot);
    }
}