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

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 155");
    shell.setLayout(new FillLayout());
    Composite composite = new Composite(shell, SWT.EMBEDDED);

    /* Draw an X using AWT */
    Frame frame = SWT_AWT.new_Frame(composite);
    Canvas canvas = new Canvas() {
        @Override//w ww . j av  a 2  s . c o m
        public void paint(Graphics g) {
            Dimension d = getSize();
            g.drawLine(0, 0, d.width, d.height);
            g.drawLine(d.width, 0, 0, d.height);
        }
    };
    frame.add(canvas);

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

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 100");
    shell.setBounds(10, 10, 200, 200);/*from w w  w .j  a  v a 2  s.  c  o m*/
    Text text = new Text(shell, SWT.MULTI);
    Rectangle clientArea = shell.getClientArea();
    text.setBounds(clientArea.x + 10, clientArea.y + 10, 150, 150);
    Font initialFont = text.getFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
        fontData[i].setHeight(24);
    }
    Font newFont = new Font(display, fontData);
    text.setFont(newFont);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    newFont.dispose();
    display.dispose();
}

From source file:MainButton.java

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Radio Buttons");
    shell.pack();//ww  w .  j av  a  2  s  .c o  m

    Button[] radios = new Button[3];

    radios[0] = new Button(shell, SWT.RADIO);
    radios[0].setSelection(true);
    radios[0].setText("Choice 1");
    radios[0].setBounds(10, 5, 75, 30);

    radios[1] = new Button(shell, SWT.RADIO);
    radios[1].setText("Choice 2");
    radios[1].setBounds(10, 30, 75, 30);

    radios[2] = new Button(shell, SWT.RADIO);
    radios[2].setText("Choice 3");
    radios[2].setBounds(10, 55, 75, 30);

    shell.open();
    shell.pack();
    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  ww  w .  jav  a2  s.co m*/

    shell.setLayout(new RowLayout());

    Button button = new Button(shell, SWT.PUSH);
    button.setText("Push Me");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            PopupList list = new PopupList(shell);
            String[] OPTIONS = { "A", "B", "C" };

            list.setItems(OPTIONS);

            String selected = list.open(shell.getBounds());

            System.out.println(selected);
        }
    });

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

From source file:TableSelectionEvent.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    for (int i = 0; i < 12; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Item " + i);
    }/* w  w w  .ja  va  2  s . c om*/
    table.setSize(100, 100);

    table.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            String string = event.detail == SWT.CHECK ? "Checked" : "Selected";
            System.out.println(event.item + " " + string);
        }
    });

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

From source file:StyledTextLineBackgroundListener.java

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("\n1234\n124\n\1234\n12314\n\1241234\n");

    styledText.addLineBackgroundListener(new LineBackgroundListener() {

        public void lineGetBackground(LineBackgroundEvent event) {
            if (event.lineText.indexOf("SWT") > -1) {
                event.lineBackground = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
            }/*w  ww. j  ava 2 s.  c  om*/

        }
    });

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

From source file:Snippet114.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);
    }//from www .j a  v a  2 s .c om
    tree.setSize(100, 100);
    tree.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            String string = event.detail == SWT.CHECK ? "Checked" : "Selected";
            System.out.println(event.item + " " + string);
        }
    });
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setSize(250, 250);/*from  w ww .  j av  a2  s .  co  m*/

    s.setText("A Shell Composite Example");

    GridLayout gl = new GridLayout();
    gl.numColumns = 4;
    s.setLayout(gl);
    s.setLayout(gl);

    GridComposite gc = new GridComposite(s);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 4;
    gc.setLayoutData(gd);
    gd = new GridData();

    RowComposite rc = new RowComposite(s);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    rc.setLayoutData(gd);

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

From source file:ComboRemoveAll.java

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

    String[] ITEMS = { "A", "B", "C", "D", "E", "F" };

    final Combo combo = new Combo(shell, SWT.DROP_DOWN);
    combo.setItems(ITEMS);/*from   ww w  .java2 s  .  co m*/

    combo.remove("C");

    combo.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            System.out.println(combo.getText());
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            System.out.println(combo.getText());
        }
    });

    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 s = new Shell(d);

    s.setSize(250, 200);/*  w  w  w.ja  va 2s. co  m*/
    s.setText("A Table Shell Example");
    s.setLayout(new FillLayout());
    Tree t = new Tree(s, SWT.SINGLE | SWT.BORDER);
    TreeItem child1 = new TreeItem(t, SWT.NONE, 0);
    child1.setText("1");
    TreeItem child2 = new TreeItem(t, SWT.NONE, 1);
    child2.setText("2");
    TreeItem child2a = new TreeItem(child2, SWT.NONE, 0);
    child2a.setText("2A");
    TreeItem child2b = new TreeItem(child2, SWT.NONE, 1);
    child2b.setText("2B");
    TreeItem child3 = new TreeItem(t, SWT.NONE, 2);
    child3.setText("3");
    s.open();
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.dispose();

}