Example usage for org.eclipse.swt.widgets Display readAndDispatch

List of usage examples for org.eclipse.swt.widgets Display readAndDispatch

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Display readAndDispatch.

Prototype

public boolean readAndDispatch() 

Source Link

Document

Reads an event from the event queue, dispatches it appropriately, and returns true if there is potentially more work to do, or false if the caller can sleep until another event is placed on the event queue.

Usage

From source file:ProgressBarUpdateUIThread.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    ProgressBar bar = new ProgressBar(shell, SWT.SMOOTH);
    bar.setBounds(10, 10, 200, 32);//from   w  ww.j av  a2  s.  c om
    shell.open();
    for (int i = 0; i <= bar.getMaximum(); i++) {
        try {
            Thread.sleep(100);
        } catch (Throwable th) {
        }
        bar.setSelection(i);
    }
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:TableScrollSelection.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);//from  w w  w  .  j av  a2  s .c om
    for (int i = 0; i < 128; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }
    table.setSelection(95);
    shell.pack();
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Flowchart.java

public static void main(String args[]) {
    Shell shell = new Shell();
    shell.setSize(200, 300);//  www . jav a  2 s . co  m
    shell.open();
    shell.setText("Flowchart");
    LightweightSystem lws = new LightweightSystem(shell);
    ChartFigure flowchart = new ChartFigure();
    lws.setContents(flowchart);

    TerminatorFigure start = new TerminatorFigure();
    start.setName("Start");
    start.setBounds(new Rectangle(40, 20, 80, 20));
    DecisionFigure dec = new DecisionFigure();
    dec.setName("Should I?");
    dec.setBounds(new Rectangle(30, 60, 100, 60));
    ProcessFigure proc = new ProcessFigure();
    proc.setName("Do it!");
    proc.setBounds(new Rectangle(40, 140, 80, 40));
    TerminatorFigure stop = new TerminatorFigure();
    stop.setName("End");
    stop.setBounds(new Rectangle(40, 200, 80, 20));

    PathFigure path1 = new PathFigure();
    path1.setSourceAnchor(start.outAnchor);
    path1.setTargetAnchor(dec.inAnchor);
    PathFigure path2 = new PathFigure();
    path2.setSourceAnchor(dec.yesAnchor);
    path2.setTargetAnchor(proc.inAnchor);
    PathFigure path3 = new PathFigure();
    path3.setSourceAnchor(dec.noAnchor);
    path3.setTargetAnchor(stop.inAnchor);
    PathFigure path4 = new PathFigure();
    path4.setSourceAnchor(proc.outAnchor);
    path4.setTargetAnchor(stop.inAnchor);

    flowchart.add(start);
    flowchart.add(dec);
    flowchart.add(proc);
    flowchart.add(stop);
    flowchart.add(path1);
    flowchart.add(path2);
    flowchart.add(path3);
    flowchart.add(path4);

    new Dnd(start);
    new Dnd(proc);
    new Dnd(dec);
    new Dnd(stop);

    Display display = Display.getDefault();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}

From source file:Snippet51.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);//  w w w  .  ja  v a 2s .co m
    for (int i = 0; i < 128; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }
    table.setTopIndex(95);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Snippet52.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);/*from   ww  w  .ja v  a  2s .com*/
    for (int i = 0; i < 128; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }
    table.setSelection(95);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ToolItemImage.java

public static void main(String[] args) {
    Display display = new Display();
    Image image = new Image(display, "yourFile.gif");
    Shell shell = new Shell(display);

    ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
    for (int i = 0; i < 12; i++) {
        ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN);
        item.setImage(image);/* w  ww.  j av a 2 s  .  c  o m*/
    }

    toolBar.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:TableCheckBoxCell.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    for (int i = 0; i < 12; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }/*from  ww w. j  a  v  a  2s . c o m*/
    table.setSize(100, 100);

    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet14.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 14");
    shell.setSize(100, 100);//  ww  w. ja v  a2  s .  c  o  m
    shell.addListener(SWT.MouseEnter, e -> System.out.println("ENTER"));
    shell.addListener(SWT.MouseExit, e -> System.out.println("EXIT"));
    shell.addListener(SWT.MouseHover, e -> System.out.println("HOVER"));
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:CreateMultipleSelectionList.java

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

    // Create a multiple-selection list
    List multi = new List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);

    // Add the items, one by one
    for (int i = 0, n = ITEMS.length; i < n; i++) {
        multi.add(ITEMS[i]);/*from  w w  w.  j  a  v a  2  s  .  c  om*/
    }

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:org.eclipse.swt.snippets.Snippet93.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 93");
    shell.setLayout(new RowLayout());
    Label label = new Label(shell, SWT.NONE);
    GC gc = new GC(label);
    Point size = gc.textExtent("Hello");
    gc.dispose();/*from   w ww  .j a v a 2s . c o m*/
    label.setText("Hello -> " + size);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}