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.Snippet293.java

public static void main(java.lang.String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 293");
    shell.setLayout(new GridLayout());

    Button b1 = new Button(shell, SWT.CHECK);
    b1.setText("State 1");
    b1.setSelection(true);/*from w  w w  .j a va 2s  . co  m*/

    Button b2 = new Button(shell, SWT.CHECK);
    b2.setText("State 2");
    b2.setSelection(false);

    Button b3 = new Button(shell, SWT.CHECK);
    b3.setText("State 3");
    b3.setSelection(true);
    b3.setGrayed(true);

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

From source file:StyleRangeSetArray.java

License:asdf

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

    final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("asdfasdfasdfasdf12345678910234567890");

    StyleRange[] ranges = new StyleRange[2];
    ranges[0] = new StyleRange(0, 3, display.getSystemColor(SWT.COLOR_GREEN), null);
    ranges[1] = new StyleRange(3, 6, display.getSystemColor(SWT.COLOR_BLUE), null);

    styledText.setStyleRanges(ranges);//from  w w  w.  jav  a2  s .  c  o m

    styledText.setBounds(10, 10, 500, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 39");
    shell.setLayout(new GridLayout());

    CCombo combo = new CCombo(shell, SWT.READ_ONLY | SWT.FLAT | SWT.BORDER);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    for (int i = 0; i < 5; i++) {
        combo.add("item" + i);
    }//from  w w w  .java2s  .c  om
    combo.setText("item0");

    combo.addSelectionListener(widgetSelectedAdapter(e -> System.out.println("Item selected")));

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

From source file:MainClass.java

public static void main(String[] a) {

    final Display d = new Display();
    final Shell shell = new Shell(d);

    shell.setSize(250, 200);/*from w  w w  .  j  a v a2 s . c o m*/

    shell.setLayout(new FillLayout());
    Text text = new Text(shell, SWT.BORDER);

    text.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent event) {
            switch (event.keyCode) {
            case SWT.CR:
                System.out.println(SWT.CR);
            case SWT.ESC:
                System.out.println(SWT.ESC);
                break;
            }
        }
    });

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

From source file:FormLayoutSingleLine.java

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

    Label label = new Label(shell, SWT.NONE | SWT.BORDER);
    label.setText("Name");

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

    FormLayout layout = new FormLayout();
    layout.marginWidth = layout.marginHeight = 5;
    shell.setLayout(layout);/*from ww  w .j  a v  a2s . co  m*/

    FormData data = new FormData(200, SWT.DEFAULT);
    text.setLayoutData(data);
    data.left = new FormAttachment(label, 5);
    data.top = new FormAttachment(label, 0, SWT.CENTER);

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

From source file:RowLayoutSpacing.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 40;//w ww . ja  v  a 2  s. com

    shell.setLayout(rowLayout);

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

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.wrap = false;//from   w ww.  ja  va  2s. c o m

    shell.setLayout(rowLayout);

    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:Snippet32.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("Can't find icon for .bmp");
    Image image = null;//from  w  w  w .  j av a2s. co m
    Program p = Program.findProgram(".bmp");
    if (p != null) {
        ImageData data = p.getImageData();
        if (data != null) {
            image = new Image(display, data);
            label.setImage(image);
        }
    }
    label.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    if (image != null)
        image.dispose();
    display.dispose();
}

From source file:RowLayoutJustify.java

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.justify = true;/*w w w . ja v a 2  s .  c  o m*/

    shell.setLayout(rowLayout);

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

public static void main(String[] args) {

    if (args.length == 0) {
        System.out.println("Usage: java Main <program id>");
        return;/*  w  w  w .jav  a 2  s. co  m*/
    }

    String progID = args[0];

    Display display = new Display();
    Shell shell = new Shell(display);

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite site = null;
    OleAutomation auto = null;
    try {
        site = new OleControlSite(frame, SWT.NONE, progID);
        auto = new OleAutomation(site);
    } catch (SWTException ex) {
        System.out.println("Unable to open type library for " + progID);
        return;
    }

    printTypeInfo(auto);

    auto.dispose();
    shell.dispose();
    display.dispose();

}