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

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

    StyledText text1 = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);

    text1.setWordWrap(!text1.getWordWrap());

    text1.setBounds(10, 10, 100, 100);/* ww  w  . ja  v a 2s  .  c o m*/
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 13");
    shell.addListener(SWT.Paint, e -> {
        e.gc.setLineWidth(4);/* w w w . j  a  v a 2s.co m*/
        e.gc.drawRectangle(20, 20, 100, 100);
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:LinkCreate.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Link link = new Link(shell, SWT.BORDER);
    link.setText("This a very simple <A href=\"htpp://www.java2s.com\">link</A> widget.");
    link.setSize(140, 40);//from   ww w.j  av a  2 s  . c  o  m
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ComboReadOnlyCreate.java

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

    // Create a read-only Combo
    Combo readOnly = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
    readOnly.setItems(ITEMS);/*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:TextAppendLine.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL);
    text.setBounds(10, 10, 100, 100);//from  ww w.  java 2  s  .  co  m
    for (int i = 0; i < 16; i++) {
        text.append("Line " + i + "\n");
    }
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ToolItemToolTip.java

public static void main(String[] args) {

    Display display = new Display();
    Shell shell = new Shell(display);

    ToolBar bar = new ToolBar(shell, SWT.BORDER);
    bar.setBounds(0, 20, 200, 64);/*from   w w  w.jav  a 2  s .c o  m*/
    ToolItem item1 = new ToolItem(bar, 0);
    item1.setToolTipText("ToolItem \n toolTip");

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

From source file:ShellStates.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.setMinimized(true);//w  ww  .j a v  a 2 s  .co m

    shell.open();
    // 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:ShellSmallImage.java

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

    Image small = new Image(display, "yourFile.gif");

    shell.setImage(small);/*w w  w . ja v  a  2s.  c  om*/

    shell.open();

    // 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:TabItemToolTip.java

public static void main(String[] args) {

    Display display = new Display();
    Shell shell = new Shell(display);

    TabFolder folder = new TabFolder(shell, SWT.BORDER);
    folder.setSize(200, 200);/*from w w  w . j  ava2s .c  o  m*/
    TabItem item0 = new TabItem(folder, 0);
    item0.setToolTipText("TabItem \n toolTip");

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

From source file:Snippet50.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Shell");
    shell.setSize(200, 200);//w  w  w  . jav  a  2  s  .c  o m
    shell.open();
    Shell dialog = new Shell(shell);
    dialog.setText("Dialog");
    dialog.setSize(200, 200);
    dialog.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}