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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);//from  w  ww. j  ava  2 s .  co m
    for (int i = 0; i < 12; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }
    TableItem item = new TableItem(table, SWT.NONE, 1);
    item.setText("*** New Item " + table.indexOf(item) + " ***");
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ClipboardExample.java

public static void main(String[] args) {
    Display display = new Display();
    new ClipboardExample().open(display);
    display.dispose();
}

From source file:FormLayoutFormData.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;//from ww w.  j a v a2  s . c o  m
    layout.marginWidth = 10;
    shell.setLayout(layout);
    Button button = new Button(shell, SWT.PUSH);
    button.setText("Button");
    FormData data = new FormData();
    data.height = 50;
    data.width = 50;
    button.setLayoutData(data);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    final Cursor cursor = display.getSystemCursor(SWT.CURSOR_HAND);
    Shell shell = new Shell(display);
    shell.setText("Snippet 44");
    shell.open();//  w w  w  .j a  va 2  s. c  o m
    final Button b = new Button(shell, 0);
    b.setText("Push to set cursor to hand");
    Rectangle clientArea = shell.getClientArea();
    b.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200);
    b.addListener(SWT.Selection, e -> b.setCursor(cursor));
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:Snippet34.java

public static void main(String[] args) {
    Display display = new Display();
    Image image = new Image(display, 16, 16);
    Color color = display.getSystemColor(SWT.COLOR_RED);
    GC gc = new GC(image);
    gc.setBackground(color);//from   w  ww .  j  a  va 2s. co  m
    gc.fillRectangle(image.getBounds());
    gc.dispose();
    Shell shell = new Shell(display);
    Label label = new Label(shell, SWT.BORDER);
    label.setImage(image);
    label.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:Snippet41.java

public static void main(String[] args) {
    String string = "This is a string\nwith a new line.";
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();//w w  w . j  av a  2s . c  o m
    TabFolder folder = new TabFolder(shell, SWT.BORDER);
    folder.setSize(200, 200);
    TabItem item0 = new TabItem(folder, 0);
    item0.setToolTipText(string);
    ToolBar bar = new ToolBar(shell, SWT.BORDER);
    bar.setBounds(0, 200, 200, 64);
    ToolItem item1 = new ToolItem(bar, 0);
    item1.setToolTipText(string);
    shell.setToolTipText(string);
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:ListScrollBottom.java

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

    // Create a List with a vertical ScrollBar
    List list = new List(shell, SWT.V_SCROLL);

    // Add a bunch of items to it
    for (int i = 0; i < 500; i++) {
        list.add("A list item");
    }//from  ww  w  . j av a2  s . c  o m

    // Scroll to the bottom
    list.select(list.getItemCount() - 1);
    list.showSelection();

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

From source file:Snippet72.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();/*from  ww w. j av  a 2s.c o  m*/
    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
    dialog.setFilterNames(new String[] { "Batch Files", "All Files (*.*)" });
    dialog.setFilterExtensions(new String[] { "*.bat", "*.*" }); // Windows
    // wild
    // cards
    dialog.setFilterPath("c:\\"); // Windows path
    dialog.setFileName("fred.bat");
    System.out.println("Save to: " + dialog.open());
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:DisplayFilterEvent.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Left click your mouse");
    shell.setSize(200, 100);/*from www.  j  a  va  2 s.  c o  m*/
    shell.open();

    shell.addListener(SWT.MouseDown, new SimpleListener("Shell mouse down listener"));

    display.addFilter(SWT.MouseDown, new SimpleListener("Display mouse down Listener"));

    display.addFilter(SWT.MouseUp, new SimpleListener("Display mouse up Listener"));

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

From source file:TextKeyEventListener.java

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

    Text t = new Text(shell, SWT.SINGLE | SWT.BORDER);
    t.setBounds(10, 85, 100, 32);/*from  w  w w.j a v  a  2s . c  om*/

    Text t2 = new Text(shell, SWT.SINGLE | SWT.BORDER);
    t2.setBounds(10, 25, 100, 32);

    t2.addListener(SWT.KeyDown, new Listener() {
        public void handleEvent(Event e) {
            System.out.println("KEY");
        }
    });

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