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

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

Introduction

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

Prototype

public void dispose() 

Source Link

Usage

From source file:org.eclipse.swt.snippets.Snippet137.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.setText("Snippet 137");
    shell.setLayout(new FillLayout());
    Browser browser;/*from w  w w .  ja va 2 s .c  o  m*/
    try {
        browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
        System.out.println("Could not instantiate Browser: " + e.getMessage());
        display.dispose();
        return;
    }
    browser.setText(html);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    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);//  w  w w . j a  v a2  s  . co m
    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:org.eclipse.swt.snippets.Snippet136.java

public static void main(String[] args) {
    String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>";
    for (int i = 0; i < 100; i++)
        html += "<P>This is line " + i + "</P>";
    html += "</BODY></HTML>";

    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 136");
    shell.setLayout(new FillLayout());
    Browser browser;//  w w  w.ja v  a2 s  .  co m
    try {
        browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
        System.out.println("Could not instantiate Browser: " + e.getMessage());
        display.dispose();
        return;
    }
    browser.setText(html);
    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(new Rectangle(5, 5, 100, 100));
    shell.pack();//w  ww . j  a  v a2 s  . c om
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:ComboSimpleCreate.java

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

    // Create a "simple" Combo
    Combo simple = new Combo(shell, SWT.SIMPLE);
    simple.setItems(ITEMS);//  w  w w.  java  2s  .  c om

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

From source file:FontMetricsCharWidth.java

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

    Text text = new Text(shell, SWT.NONE);

    GC gc = new GC(text);
    FontMetrics fm = gc.getFontMetrics();
    int charWidth = fm.getAverageCharWidth();
    int width = text.computeSize(charWidth * 8, SWT.DEFAULT).x;
    gc.dispose();//  w w  w .  ja v a 2  s.c om

    System.out.println(width);

    shell.isDisposed();
    display.dispose();
}

From source file:CreateDropCombo.java

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

    // Create a dropdown Combo
    Combo combo = new Combo(shell, SWT.DROP_DOWN);
    combo.setItems(ITEMS);/*from   www .  j a v a 2s .  com*/

    shell.open();
    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);//from   w w w.  j  ava2 s  . co  m
    shell.open();
    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 .ja  v a2 s.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: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);/*from   ww  w.j a  v  a 2  s  .c o  m*/
        e.gc.drawRectangle(20, 20, 100, 100);
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}