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

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

Introduction

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

Prototype

public boolean sleep() 

Source Link

Document

Causes the user-interface thread to sleep (that is, to be put in a state where it does not consume CPU cycles) until an event is received or it is otherwise awakened.

Usage

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  a  v a 2 s.  c  o m*/
    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);/*from   ww w. jav  a  2 s . c o  m*/
    dialog.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            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();//ww  w . jav a2s. c om
    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:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setText("A Shell Composite Example");
    s.setLayout(new FillLayout());
    TextPaneComposite tpc = new TextPaneComposite(s);

    s.open();//from   w  ww  .  j a v  a2  s. com
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.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();//from w  w  w. j a  va  2 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 ww.j  av a2 s.c om*/

    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();
}

From source file:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setSize(250, 250);// w  w w  . ja  v a  2 s .  co  m
    s.setText("A Text Example");
    final Text text1 = new Text(s, SWT.SINGLE);
    text1.setBounds(10, 10, 100, 20);

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

From source file:SWTFirst.java

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

    shell.setText("Hello, world!");

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

From source file:SingleLinefieldTextExample.java

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

    // Create a single-line text field
    new Text(shell, SWT.BORDER);

    shell.open();//from  w ww. j a v a2s  .c  o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:HTMLRendererInMemory.java

public static void main(String[] args) {
    String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>";
    for (int i = 0; i < 100; i++) {
        html += "<a href=\"http://www.java2s.com\">java2s.com</a><br><br>";
    }//from ww  w.j  a v  a  2 s.  c  o m
    html += "</BODY></HTML>";

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Browser browser = new Browser(shell, SWT.NONE);
    browser.setText(html);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}