Example usage for org.eclipse.swt.widgets Tree setRedraw

List of usage examples for org.eclipse.swt.widgets Tree setRedraw

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Tree setRedraw.

Prototype

public void setRedraw(boolean redraw) 

Source Link

Document

If the argument is false, causes subsequent drawing operations in the receiver to be ignored.

Usage

From source file:TreeSingleSelection.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("TreeExample");

    Tree tree = new Tree(shell, SWT.SINGLE | SWT.BORDER);

    // Turn off drawing to avoid flicker
    tree.setRedraw(false);

    for (int i = 0; i < 5; i++) {
        TreeItem item = new TreeItem(tree, SWT.NONE);
        item.setText("Root Item " + i);

        for (int j = 0; j < 3; j++) {
            TreeItem child = new TreeItem(item, SWT.NONE);
            child.setText("Child Item " + i + " - " + j);

            for (int k = 0; k < 3; k++) {
                TreeItem grandChild = new TreeItem(child, SWT.NONE);
                grandChild.setText("Grandchild Item " + i + " - " + j + " - " + k);
            }/*from   w w  w .j ava 2s  .c o  m*/
        }
    }
    tree.setRedraw(true);

    tree.setBounds(10, 10, 400, 400);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:TreeMultiSelection.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);

    shell.setText("TreeExample");

    Tree tree = new Tree(shell, SWT.MULTI | SWT.BORDER);

    // Turn off drawing to avoid flicker
    tree.setRedraw(false);

    for (int i = 0; i < 5; i++) {
        TreeItem item = new TreeItem(tree, SWT.NONE);
        item.setText("Root Item " + i);

        for (int j = 0; j < 3; j++) {
            TreeItem child = new TreeItem(item, SWT.NONE);
            child.setText("Child Item " + i + " - " + j);

            for (int k = 0; k < 3; k++) {
                TreeItem grandChild = new TreeItem(child, SWT.NONE);
                grandChild.setText("Grandchild Item " + i + " - " + j + " - " + k);
            }// w w w .j  a v  a 2s  .c  om
        }
    }
    tree.setRedraw(true);

    tree.setBounds(10, 10, 400, 400);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:SWTTreeExample.java

/**
 * Helper method to fill a tree with data
 * // ww w. j  a  v  a 2  s  . c o m
 * @param tree the tree to fill
 */
private void fillTree(Tree tree) {
    // Turn off drawing to avoid flicker
    tree.setRedraw(false);

    // Create five root items
    for (int i = 0; i < 5; i++) {
        TreeItem item = new TreeItem(tree, SWT.NONE);
        item.setText("Root Item " + i);

        // Create three children below the root
        for (int j = 0; j < 3; j++) {
            TreeItem child = new TreeItem(item, SWT.NONE);
            child.setText("Child Item " + i + " - " + j);

            // Create three grandchildren under the child
            for (int k = 0; k < 3; k++) {
                TreeItem grandChild = new TreeItem(child, SWT.NONE);
                grandChild.setText("Grandchild Item " + i + " - " + j + " - " + k);
            }
        }
    }
    // Turn drawing back on!
    tree.setRedraw(true);
}