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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    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 w w. j a  v  a2 s.  c  o  m*/
    label.setText("Hello -> " + size);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:MainClass.java

public static void main(String[] a) {

    final Display d = new Display();
    final Shell shell = new Shell(d);

    shell.setSize(250, 200);// w w w .  ja  v  a  2  s  .co  m

    shell.setLayout(new FillLayout());

    Canvas drawingCanvas = new Canvas(shell, SWT.NONE);
    drawingCanvas.addPaintListener(new ArcExamplePaintListener());
    drawingCanvas.redraw();

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

From source file:WidgetDisposeListener.java

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

    shell.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            System.out.println(e.widget + " disposed");
        }/*from w w w  .ja v a2 s .c o m*/
    });

    shell.setSize(260, 120);
    shell.open();

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

From source file:StyledTextActionBoundArrowShift.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    int shiftLeftAction = styledText.getKeyBinding(SWT.ARROW_LEFT | SWT.SHIFT);

    styledText.setBounds(10, 10, 100, 100);
    shell.open();//from   ww w .  j  av a  2 s.c o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:PrintWarning.java

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

    Device device = shell.getDisplay();/* ww  w . j a  v a2 s .  c  o m*/

    // By setting warnings to true and then getting warnings, we know if the
    // current platform supports it
    device.setWarnings(true);
    System.out.println("Warnings supported: " + device.getWarnings());

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

}

From source file:CLabelWithTextImage.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());

    CLabel label = new CLabel(shell, SWT.BORDER);
    label.setText("text on the label");

    label.setImage(new Image(display, "yourFile.gif"));
    shell.open();//  ww w .j a v  a2s  .  co  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:CLabelBackgroundImage.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());

    CLabel label = new CLabel(shell, SWT.BORDER);
    label.setText("text on the label");

    label.setBackground(new Image(display, "yourFile.gif"));
    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:CLabelLeftShadowIn.java

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

    shell.setLayout(new GridLayout(1, false));

    CLabel left = new CLabel(shell, SWT.LEFT | SWT.SHADOW_IN);
    left.setText("Left and Shadow In");
    left.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    shell.open();/*w w  w.j av a  2 s .  c  o m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:PushButtonExample.java

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

    // Create three push buttons
    new Button(shell, SWT.PUSH).setText("Push 1");
    new Button(shell, SWT.PUSH).setText("Push 2");
    new Button(shell, SWT.PUSH).setText("Push 3");

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

From source file:ListCreateAddItemsToIt.java

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

    // Create a List with a vertical ScrollBar
    List list = new List(shell, SWT.V_SCROLL);

    // Add a bunch of items to it
    for (int i = 0; i < 500; i++) {
        list.add("A list item");
    }/*from  w  w w. j  av a 2s  . c om*/

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