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

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

Introduction

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

Prototype

public boolean readAndDispatch() 

Source Link

Document

Reads an event from the event queue, dispatches it appropriately, and returns true if there is potentially more work to do, or false if the caller can sleep until another event is placed on the event queue.

Usage

From source file:StyledTextCreate.java

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

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

    text.setBounds(10, 10, 100, 100);/*from  ww w .  j  av a  2 s  .  c  o  m*/

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

}

From source file:PasswordFieldTextExample.java

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

    // Create a password text field
    new Text(shell, SWT.PASSWORD | SWT.BORDER);

    shell.open();// w w  w .  j  av a 2 s . com
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:BrowserLoadingWebsite.java

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

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);/*w ww. ja  va  2 s  .c  o m*/

    browser.setUrl("http://java2s.com");
    shell.open();

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

From source file:RenderHTML.java

public static void main(String[] args) {
    /* Relative links: use the HTML base tag */
    String html = "<html><head>"
            + "<base href=\"http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/\" >"
            + "<title>HTML Test</title></head>" + "<body><a href=\"dev.html\">local link</a></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);/*from   w ww .j  a  v a 2 s  .c  o  m*/
    shell.open();
    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);//from   ww w.  j  a  va  2 s  . co m
    s.setText("A Text Example");
    final Text text1 = new Text(s, SWT.SINGLE | SWT.BORDER);
    text1.setBounds(10, 10, 100, 20);

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

From source file:Snippet45.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Scale scale = new Scale(shell, SWT.BORDER);
    scale.setSize(200, 64);/*  ww w .  j  a v a  2 s  . c  o m*/
    scale.setMaximum(40);
    scale.setPageIncrement(5);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Snippet22.java

License:asdf

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Text text = new Text(shell, 0);
    text.setText("ASDF");
    text.setSize(64, 32);//from   www  .j  a  va  2 s.c o  m
    text.selectAll();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:HTMLRenderRelativeMemory.java

public static void main(String[] args) {
    /* Relative links: use the HTML base tag */
    String html = "<html><head>" + "<base href=\"http://www.eclipse.org/swt/\" >"
            + "<title>HTML Test</title></head>" + "<body><a href=\"faq.php\">local link</a></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);//  w  w  w  .ja  va  2  s .  c  o  m
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:NoLayoutSimple.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Button button = new Button(shell, SWT.PUSH);
    button.setText("No layout");
    button.setBounds(5, 5, 50, 150);/*  w  w  w . j  a  va2s .  c  o m*/

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

From source file:FileDialogFilterExtensions.java

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

    FileDialog dialog = new FileDialog(shell);
    dialog.setFilterExtensions(new String[] { "*.ico", "*.gif", "*.*" });
    String name = dialog.open();/* w w  w  .j  a v a  2 s  .  co  m*/

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

    display.dispose();
}