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

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

    Device device = shell.getDisplay();/*w w  w. j  a va  2  s  . c o  m*/

    // By setting warnings to true and then getting warnings, we know if the
    // current platform supports it
    device.setWarnings(true);
    System.out.println("Warnings supported: " + device.getWarnings());

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

}

From source file:LabelTextImageAlignment.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());

    Label label = new Label(shell, SWT.BORDER | SWT.RIGHT);
    label.setText("text on the label");

    shell.open();/*w ww. j  ava 2s .  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:org.eclipse.swt.snippets.Snippet22.java

License:asdf

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 22");
    Text text = new Text(shell, 0);
    text.setText("ASDF");
    Rectangle clientArea = shell.getClientArea();
    text.setBounds(clientArea.x, clientArea.y, 64, 32);
    text.selectAll();/*w  w  w  .  j a v a2  s .  com*/
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("PowerPoint Example");
    shell.setLayout(new FillLayout());
    try {/*from w  w  w.  j a v a2 s  . c  o m*/
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        clientSite = new OleClientSite(frame, SWT.NONE, "PowerPoint.Slide");
        addFileMenu(frame);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }
    shell.setSize(800, 600);
    shell.open();

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

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 45");
    Scale scale = new Scale(shell, SWT.BORDER);
    Rectangle clientArea = shell.getClientArea();
    scale.setBounds(clientArea.x, clientArea.y, 200, 64);
    scale.setMaximum(40);//www  .  j av a2 s  .c  o m
    scale.setPageIncrement(5);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Word Example");
    shell.setLayout(new FillLayout());
    try {// w ww.  j  av  a  2s  .c  om
        frame = new OleFrame(shell, SWT.NONE);
        clientSite = new OleClientSite(frame, SWT.NONE, "Word.Document");
        addFileMenu(frame);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }
    shell.setSize(800, 600);
    shell.open();

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

From source file:LabelShadowInOut.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());

    Label label = new Label(shell, SWT.BORDER | SWT.SHADOW_OUT);
    label.setText("text on the label");

    shell.open();/*from   ww w  .j a  va  2  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:CLabelLeftShadowIn.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("CLabel Test");

    shell.setLayout(new GridLayout(1, false));

    CLabel left = new CLabel(shell, SWT.LEFT | SWT.SHADOW_IN);
    left.setText("Left and Shadow In");
    left.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    shell.open();/*  ww w . jav a2  s  . co  m*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:PushButtonExample.java

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

    // Create three push buttons
    new Button(shell, SWT.PUSH).setText("Push 1");
    new Button(shell, SWT.PUSH).setText("Push 2");
    new Button(shell, SWT.PUSH).setText("Push 3");

    shell.pack();//from w  ww . j av  a  2s.c  o m
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:Snippet12.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL);
    text.setBounds(10, 10, 100, 100);/* w  w  w. jav  a2s. c o  m*/
    for (int i = 0; i < 16; i++) {
        text.append("Line " + i + "\n");
    }
    shell.open();
    text.setSelection(30, 38);
    System.out.println(text.getCaretLocation());
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}