Insert TreeItem to Tree : Tree « SWT « Java Tutorial

Insert TreeItem to Tree
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

public class TreeItemInsert {

  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Tree tree = new Tree(shell, SWT.BORDER | SWT.MULTI);
    tree.setSize(200, 200);
    for (int i = 0; i < 5; i++) {
      TreeItem item = new TreeItem(tree, SWT.NONE);
      item.setText("Item " + i);
    TreeItem item = new TreeItem(tree, SWT.NONE, 1);
    item.setText("*** New Item ***");
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())


17.57.2.Create a TreeCreate a Tree
17.57.3.Populate tree lazilyPopulate tree lazily
17.57.4.Create Three Level TreeCreate Three Level Tree
17.57.5.Insert TreeItem to TreeInsert TreeItem to Tree
17.57.6.Add checkbox mark to the tree nodeAdd checkbox mark to the tree node
17.57.7.A multiselection treeA multiselection tree
17.57.8.A single-selection treeA single-selection tree