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

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setSize(300, 200);//ww w. j  a va  2 s. c o m
    shell.setLayout(new RowLayout());

    final Composite composite = new Composite(shell, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 4;
    composite.setLayout(gridLayout);

    for (int loopIndex = 0; loopIndex < 18; loopIndex++) {
        Button button = new Button(composite, SWT.PUSH);
        button.setText("Button " + loopIndex);
    }

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

From source file:CoolBarToolBar.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    CoolBar coolBar = new CoolBar(shell, SWT.BORDER);
    coolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    final CoolItem item = new CoolItem(coolBar, SWT.DROP_DOWN);
    item.setControl(createToolBar(coolBar));

    Control control = item.getControl();
    Point pt = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    pt = item.computeSize(pt.x, pt.y);/*w  w  w  .j  a  va 2s .co m*/
    item.setSize(pt);

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

From source file:ScrollBarSelectionValue.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");
    }/* w w w  .j av a2 s .co m*/

    // Get the ScrollBar
    ScrollBar sb = list.getVerticalBar();
    // Show the selection value
    System.out.println("Selection: " + sb.getSelection());

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

From source file:TreeNodeCheckBoxAdd.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Tree tree = new Tree(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    for (int i = 0; i < 12; i++) {
        TreeItem item = new TreeItem(tree, SWT.NONE);
        item.setText("Item " + i);
        for (int l = 0; l < 12; l++) {
            TreeItem litem = new TreeItem(item, SWT.NONE);
            litem.setText("Item " + i);
        }/*from  w  w w.j av a2 s .c  o  m*/

    }
    tree.setSize(100, 100);

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

From source file:Snippet108.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Label label = new Label(shell, SWT.NONE);
    label.setText("Enter your name:");
    Text text = new Text(shell, SWT.BORDER);
    text.setLayoutData(new RowData(100, SWT.DEFAULT));
    Button ok = new Button(shell, SWT.PUSH);
    ok.setText("Ok");
    Button cancel = new Button(shell, SWT.PUSH);
    cancel.setText("Cancel");
    shell.setDefaultButton(cancel);/*from w  w w.  j  a va  2  s .c o  m*/
    shell.setLayout(new RowLayout());
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:RowLayoutDefaultValue.java

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

    RowLayout rowLayout = new RowLayout();

    shell.setLayout(rowLayout);//from   w w  w  .  j a v  a  2  s  .  co  m

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

    shell.setSize(450, 100);
    shell.open();

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

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

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 347");
    shell.setLayout(new GridLayout(1, false));
    Menu appMenuBar = display.getMenuBar();
    if (appMenuBar == null) {
        appMenuBar = new Menu(shell, SWT.BAR);
        shell.setMenuBar(appMenuBar);//from  ww  w  .j  a  va 2s  .  c o m
    }
    MenuItem file = new MenuItem(appMenuBar, SWT.CASCADE);
    file.setText("File");
    Menu dropdown = new Menu(appMenuBar);
    file.setMenu(dropdown);
    MenuItem exit = new MenuItem(dropdown, SWT.PUSH);
    exit.setText("Exit");
    exit.addSelectionListener(widgetSelectedAdapter(e -> display.dispose()));
    Button b = new Button(shell, SWT.PUSH);
    b.setText("Test");
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:GridLayoutDefaultValues.java

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

    GridLayout gridLayout = new GridLayout();

    shell.setLayout(gridLayout);/*from  www  .  ja va  2 s  .com*/

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

    shell.setSize(450, 200);
    shell.open();

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

From source file:FormLayoutLeftRight.java

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

    shell.setLayout(new FormLayout());

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    FormData formData = new FormData();
    formData.left = new FormAttachment(20);
    formData.top = new FormAttachment(20);
    button1.setLayoutData(formData);/*ww  w  .j  a  va  2 s  .  c o m*/

    shell.pack();
    shell.open();
    // 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:TextStrikeout.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("StyledText with underline and strike through");
    shell.setLayout(new FillLayout());
    StyledText text = new StyledText(shell, SWT.BORDER);
    text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");

    // make 0123456789 appear strikeout
    StyleRange style1 = new StyleRange();
    style1.start = 0;/*from   www  . ja  va  2  s .com*/
    style1.length = 10;
    style1.strikeout = true;
    text.setStyleRange(style1);

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