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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();/*from w  ww.  j  a  v a2s  .  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");
        }//from  ww 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 w  w  w  .  j  a va  2s.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();//from  w  w w  .j av  a 2s  .  c  o m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}

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);/*from w  ww  .  j a va  2  s. c o  m*/

    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: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  ww  .j  a  v  a2s. c  o  m*/
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    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  w  w  w.  ja  va 2  s  . com
    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();//from  w ww.j  a  va2 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();
}

From source file:TimerOneShot2000.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(200, 200);//from  w w  w. java  2 s  .  c om
    shell.open();
    display.timerExec(2000, new Runnable() {
        public void run() {
            System.out.println("2000");
        }
    });

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

From source file:SeparatorHorizontalVertical.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    new Label(shell, SWT.SEPARATOR | SWT.VERTICAL);
    shell.setSize(200, 200);/* w  w w.  j a v a 2  s.c  om*/
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}