The Tree is familiar to most people who use computers. It is a way of showing a hierarchical structure via a list where each item in the list can be opened up to show a sub-list.
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.
With a Tree widget, then, all you can do is a) add it to wherever you want it to appear, and
b) add branches to it. There are other methods, of course, mostly inherited from elsewhere,
the two more important to the Tree methods are ensureSelectedItemVisible() and
getItem().
To capture when a TreeItem is opened, closed or selected, add a TreeListener to the Tree
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);
}
}