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

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new RowLayout());

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

    shell.open();//w  ww .  j av a 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:LayoutDataControlLayout.java

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

    shell.setLayout(new GridLayout()); // Only with GridLayout you can use GridData
    Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
    text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));

    shell.setSize(450, 100);//  ww  w  . ja v  a2  s  .c om
    shell.open();

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

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

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Media Player Example");
    shell.setLayout(new FillLayout());
    try {//from w ww  .  j a  v a2s . c  o  m
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        clientSite = new OleClientSite(frame, SWT.NONE, "MPlayer");
        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:ButtonBasics.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new RowLayout());

    Button button = new Button(shell, SWT.RIGHT);

    button.setText("text on the button");

    shell.open();/*from   w  ww  .  java  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:ButtonTextAlignment.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());

    Button button = new Button(shell, SWT.RIGHT);

    button.setText("text on the button");

    shell.open();/*from   w  w  w  . j  av  a2s.c om*/
    // 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:ShellResizeEvent.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL);

    shell.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event e) {
            Rectangle rect = shell.getClientArea();
            System.out.println(rect);
        }//from  ww  w .  j a va2  s.  c om
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:EscapeMnemonicCharacter.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new RowLayout());

    Button button = new Button(shell, SWT.RIGHT);

    button.setText("&&text on the button");

    shell.open();/*from w w  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:Snippet184.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Spinner spinner = new Spinner(shell, SWT.BORDER);
    spinner.setMinimum(0);/*from  w w  w . ja v  a2  s  .  c om*/
    spinner.setMaximum(1000);
    spinner.setSelection(500);
    spinner.setIncrement(1);
    spinner.setPageIncrement(100);
    spinner.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 33");
    shell.open();/*from  w  ww . j av a2s  .c om*/
    DirectoryDialog dialog = new DirectoryDialog(shell);
    String platform = SWT.getPlatform();
    dialog.setFilterPath(platform.equals("win32") ? "c:\\" : "/");
    System.out.println("RESULT=" + dialog.open());
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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

    int shiftLeftAction = styledText.getKeyBinding(SWT.ARROW_LEFT | SWT.SHIFT);

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

}