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

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

    GC gc = new GC(shell);
    Point size = gc.textExtent("Hellooooooooooooooooooooo");

    System.out.println("Hello -> " + size);
    shell.pack();//from  w  w  w  .j  a va2s  .c o  m
    shell.open();

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

From source file:CreateDropCombo.java

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

    // Create a dropdown Combo
    Combo combo = new Combo(shell, SWT.DROP_DOWN);
    combo.setItems(ITEMS);/*  ww w . j av  a  2s.co  m*/

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

From source file:Snippet33.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();/*  www .  ja va2  s  .  co  m*/
    DirectoryDialog dialog = new DirectoryDialog(shell);
    dialog.setFilterPath("c:\\"); // Windows specific
    System.out.println("RESULT=" + dialog.open());
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:SystemSettingChangeListener.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    display.addListener(SWT.Settings, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("Setting changed");
        }/* w  w w. j  a  v  a  2 s. c o  m*/
    });

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

From source file:DeviceDisplayBoundary.java

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

    Device device = shell.getDisplay();//from ww  w .j a va 2  s  .  c  o m

    System.out.println("getBounds(): " + device.getBounds());
    System.out.println("getClientArea(): " + device.getClientArea());

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

}

From source file:ShellStyleTrimTool.java

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

    shell.setLayout(new GridLayout());

    Button button = new Button(shell, SWT.PUSH | SWT.LEFT);
    button.setText("Button");

    shell.open();/* w ww  . j  a v  a  2s . co m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

From source file:FormLayoutFormDataAttachment.java

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

    shell.setLayout(new FormLayout());

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    shell.setSize(450, 400);//from w  w w  .j  av a2s  .com
    shell.open();

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

From source file:CursorImageCreate.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setSize(150, 150);//w w  w. j ava  2  s  . c om

    Cursor cursor = new Cursor(display, new Image(display, "yourFile.gif").getImageData(), 0, 0);
    shell.setCursor(cursor);

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

From source file:Snippet178.java

public static void main(String[] arg) {
    Display.setAppName("AppMenu"); // sets name in Dock
    Display display = new Display();
    hookApplicationMenu(display, "About AppMenu");
    Shell shell = new Shell(display);
    shell.setText("Main Window");
    shell.open();//from ww w  . j av a 2s  . co m
    while (!shell.isDisposed())
        if (!display.readAndDispatch())
            display.sleep();

    display.dispose();
}

From source file:CursorSetControl.java

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

    Cursor cursor = new Cursor(display, SWT.CURSOR_HAND);

    Shell shell = new Shell(display);
    shell.open();/*  w w  w .j  a  v a 2 s.  c om*/
    final Button b = new Button(shell, 0);
    b.setBounds(10, 10, 200, 200);
    b.setCursor(cursor);

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