Instances of this class provide a selectable user interface object
that displays a hierarchy of items and issues notification when an
item in the hierarchy is selected.
The item children that may be added to instances of this class
must be of type TreeItem.
Style VIRTUAL is used to create a Tree whose
TreeItems are to be populated by the client on an on-demand basis
instead of up-front. This can provide significant performance improvements for
trees that are very large or for which TreeItem population is
expensive (for example, retrieving values from an external source).
Here is an example of using a Tree with style VIRTUAL:
final Tree tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
tree.setItemCount(20);
tree.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TreeItem item = (TreeItem)event.item;
TreeItem parentItem = item.getParentItem();
String text = null;
if (parentItem == null) {
text = "node " + tree.indexOf(item);
} else {
text = parentItem.getText() + " - " + parentItem.indexOf(item);
}
item.setText(text);
System.out.println(text);
item.setItemCount(10);
}
});
Note that although this class is a subclass of Composite,
it does not make sense to add Control children to it,
or set a layout on it.
The item children that may be added to instances of this class must be of type
TreeItem.Style
VIRTUALis used to create aTreewhoseTreeItems are to be populated by the client on an on-demand basis instead of up-front. This can provide significant performance improvements for trees that are very large or for whichTreeItempopulation is expensive (for example, retrieving values from an external source).Here is an example of using a
Treewith styleVIRTUAL:final Tree tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER); tree.setItemCount(20); tree.addListener(SWT.SetData, new Listener() { public void handleEvent(Event event) { TreeItem item = (TreeItem)event.item; TreeItem parentItem = item.getParentItem(); String text = null; if (parentItem == null) { text = "node " + tree.indexOf(item); } else { text = parentItem.getText() + " - " + parentItem.indexOf(item); } item.setText(text); System.out.println(text); item.setItemCount(10); } });Note that although this class is a subclass of
Composite, it does not make sense to addControlchildren to it, or set a layout on it.Note: Only one of the styles SINGLE and MULTI may be specified.
IMPORTANT: This class is not intended to be subclassed.