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:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);
    s.setSize(500, 500);/*w  w w  .jav a  2  s.c o  m*/
    s.setImage(new Image(d, "c:\\icons\\yourico.ico"));
    s.setText("A Shell Example");
    s.open();
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.dispose();
}

From source file:org.eclipse.swt.examples.graphics.AdvancedGraphics.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new AdvancedGraphics().open(display);
    while (shell != null && !shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();/*from  w  w  w.j ava2  s. c o  m*/
    }
    display.dispose();
}

From source file:ShellOnTop.java

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

    shell.open();//from   w  ww .ja v  a  2s.c  o  m
    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            // If no more entries in event queue
            display.sleep();
        }
    }
    display.dispose();
}

From source file:ShellTrimCloseTitleMinMax.java

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

    shell.open();/*  w w  w .ja v  a2  s  .c o m*/
    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            // If no more entries in event queue
            display.sleep();
        }
    }
    display.dispose();
}

From source file:DialogShellCreate.java

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

    Shell dialog = new Shell(shell);
    dialog.setText("Dialog");
    dialog.setSize(200, 200);//w ww  .j  a va2 s.c  o  m
    dialog.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ShellApplicationModal.java

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

    shell.open();/* w ww  .  j a v  a 2 s  .  c  o  m*/
    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            // If no more entries in event queue
            display.sleep();
        }
    }
    display.dispose();
}

From source file:ShellToolWindow.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.TOOL);
    shell.setLayout(new FillLayout());

    shell.open();/*w  w w.  j a  va 2s  .com*/
    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            // If no more entries in event queue
            display.sleep();
        }
    }
    display.dispose();
}

From source file:ThickLinkDraw.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();//w ww . j  av  a  2 s.co  m
    GC gc = new GC(shell);
    gc.setLineWidth(4);
    gc.drawRectangle(20, 20, 100, 100);
    gc.dispose();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:SeparatorLabelExample.java

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

    // Create a vertical separator
    new Label(shell, SWT.SEPARATOR);

    shell.open();//  w ww  . ja va2  s . c o m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:DrawLine.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();/*  w  w w.  j  a v  a  2 s .co m*/

    GC gc = new GC(shell);

    gc.drawLine(0, 0, 19, 19);
    gc.drawLine(19, 0, 0, 19);

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

    display.dispose();
}