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

public static void main(String[] args) {
    Display display = new Display();
    final Cursor cursor = new Cursor(display, SWT.CURSOR_HAND);
    Shell shell = new Shell(display);
    shell.open();// w ww .  j a  va 2  s  .com
    final Button b = new Button(shell, 0);
    b.setBounds(10, 10, 200, 200);
    b.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            b.setCursor(cursor);
        }
    });
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    cursor.dispose();
    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();/*from   ww  w. j av a2  s  .  c o 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:TrackerMouseDown.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.open();/*from  w w w .  j  a  v a 2  s .  c o m*/
    shell.addListener(SWT.MouseDown, new Listener() {
        public void handleEvent(Event e) {
            Tracker tracker = new Tracker(shell, SWT.NONE);
            tracker.setRectangles(new Rectangle[] { new Rectangle(e.x, e.y, 100, 100), });
            tracker.open();
        }
    });
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:WidgetBoundsSetting.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setBounds(10, 10, 200, 200);//w  w w  .  ja va  2 s .  com

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("&Typical button");
    button1.setBounds(10, 10, 180, 30);
    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("&Overidden button");
    button2.setBounds(10, 50, 180, 30);

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

From source file:MainClass.java

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

    ProgressBar pb1 = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH);
    pb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    pb1.setMinimum(0);// w w w  .  ja  va  2 s. c om
    pb1.setMaximum(30);

    new LongRunningOperation(display, pb1).start();

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

From source file:FormLayoutFormDataWidthHeight.java

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

    shell.setLayout(new FormLayout());

    FormData formData = new FormData();
    formData.width = 100;/*from ww  w  .java  2s  . c o  m*/
    formData.height = 200;

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

    shell.setSize(450, 400);
    shell.open();

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

From source file:StyledTextClearKeyBinding.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");

    styledText.setKeyBinding('i' | SWT.ALT, ST.TOGGLE_OVERWRITE);

    //clear/* w w  w .  ja v  a2s.  c o m*/
    styledText.setKeyBinding('i' | SWT.ALT, SWT.NULL);

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:Snippet120.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(200, 200);/*from   www  .  j  av a 2  s. com*/
    Monitor primary = display.getPrimaryMonitor();
    Rectangle bounds = primary.getBounds();
    Rectangle rect = shell.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shell.setLocation(x, y);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:StyledTextPaint.java

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

    Shell shell = new Shell(display);
    shell.setBounds(10, 10, 250, 250);/* w ww .j  av  a  2 s  . c om*/
    final StyledText text = new StyledText(shell, SWT.NONE);
    text.setBounds(10, 10, 200, 200);
    text.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("paint");

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

From source file:Snippet78.java

public static void main(String[] args) {

    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    final Label label1 = new Label(shell, SWT.BORDER);
    label1.setText("TEXT");
    final Label label2 = new Label(shell, SWT.BORDER);
    setDragDrop(label1);/* w  w w. ja v a 2s. c o  m*/
    setDragDrop(label2);
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}