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

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

    PrintDialog dlg = new PrintDialog(shell);
    PrinterData printerData = dlg.open();
    if (printerData != null) {

        System.out.println(printerData.printToFile);

        // Printer printer = new Printer(printerData);
        // Use printer . . .
        // printer.dispose();
    }// w ww  .  j  av a  2  s .c  om

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

From source file:ImageRegistryUsing.java

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

    ImageRegistry ir = new ImageRegistry();
    ir.put("image1", new Image(display, "yourFile.gif"));

    Button executeButton = new Button(shell, SWT.PUSH);
    executeButton.setText("Execute");
    executeButton.setImage(ir.get("image1"));

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

From source file:StyledTextLineBackground.java

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

    final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("\n1234\n124\n\1234\n12314\n\1241234\n");

    styledText.setLineBackground(0, 6, Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));

    styledText.setBounds(10, 10, 500, 100);
    shell.open();/*w w  w  .  j  a  v a 2  s . c om*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    Image image = display.getSystemImage(SWT.ICON_QUESTION);
    Shell shell = new Shell(display);
    shell.setText("Snippet 206");
    shell.setLayout(new GridLayout());
    Button button = new Button(shell, SWT.PUSH);
    button.setImage(image);/*  w w  w. ja v  a 2s  .  co m*/
    button.setText("Button");
    shell.setSize(300, 300);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:DrawOval.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent event) {
            Rectangle rect = shell.getClientArea();
            event.gc.drawOval(0, 0, rect.width - 1, rect.height - 1);
        }/*from w  w w.ja va2  s.c o  m*/
    });
    shell.setBounds(10, 10, 200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 19");
    Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL);
    Rectangle clientArea = shell.getClientArea();
    text.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200);
    text.addVerifyListener(Snippet19::ensureTextContainsOnlyDigits);
    shell.open();//from   w w  w  .j  a  v a 2  s  .  c  om
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:MainClass.java

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

    PrintDialog dlg = new PrintDialog(shell);

    dlg.setScope(PrinterData.SELECTION);

    PrinterData printerData = dlg.open();
    if (printerData != null) {
        Printer printer = new Printer(printerData);
        System.out.println(printer.getClientArea());
        printer.dispose();/* ww  w .  j  av a 2 s. co m*/
    }

    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 .jav a  2 s.  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:FormLayoutAttachControl.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.left = new FormAttachment(50);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");
    button1.setLayoutData(formData);/*from w  w w . j a v a2 s .c  o  m*/

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

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

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Main Window");
    shell.setLayout(new FillLayout());
    Browser browser = new Browser(shell, SWT.NONE);
    initialize(display, browser);//from w  ww  . j  av a  2 s .  c om
    shell.open();
    /* any website with popups */
    browser.setUrl("http://www.cnn.com");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}