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

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

    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.VERTICAL;//w  w w . j  a  v  a 2s  . c  om

    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:org.eclipse.swt.snippets.Snippet290.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 290");
    shell.addMouseListener(new MouseAdapter() {
        @Override/*  ww w .  ja v  a 2 s.  co m*/
        public void mouseUp(MouseEvent e) {
            if (e.count == 1) {
                System.out.println("Mouse up");
            }
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            System.out.println("Double-click");
        }
    });
    shell.setBounds(10, 10, 200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:FontChangeSWT.java

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

    Canvas canvas = new Canvas(shell, SWT.NONE);

    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {

            Font font = new Font(shell.getDisplay(), "Helvetica", 18, SWT.NORMAL);
            e.gc.setFont(font);/*w w  w .  j a  va 2s  .c  o  m*/
            e.gc.drawText("My Text", 0, 0);
            font.dispose();

        }
    });

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

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

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 243");
    shell.setLayout(new FillLayout());
    final Text text0 = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    final Text text1 = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    text0.addVerifyListener(event -> {
        text1.setTopIndex(text0.getTopIndex());
        text1.setSelection(event.start, event.end);
        text1.insert(event.text);/* w w w  .j av  a  2s.  c  om*/
    });
    shell.setBounds(10, 10, 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) {

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

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

    shell.setLayout(new FillLayout());

    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);

    Composite child = new Composite(sc, SWT.NONE);
    child.setLayout(new FillLayout());

    new Button(child, SWT.PUSH).setText("One");
    new Button(child, SWT.PUSH).setText("Two");
    sc.setContent(child);

    sc.setMinSize(300, 300);

    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);

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

From source file:Snippet36.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 w  w .j  a  va 2 s .  co m
    gc.fillRectangle(image.getBounds());
    gc.dispose();
    Shell shell = new Shell(display);
    ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
    for (int i = 0; i < 12; i++) {
        ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN);
        item.setImage(image);
    }
    toolBar.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 24");
    shell.setLayout(new RowLayout());
    Combo combo = new Combo(shell, SWT.NONE);
    combo.setItems("A-1", "B-1", "C-1");
    Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
    text.setText("some text");
    combo.addListener(SWT.DefaultSelection, e -> System.out.println(e.widget + " - Default Selection"));
    text.addListener(SWT.DefaultSelection, e -> System.out.println(e.widget + " - Default Selection"));
    shell.pack();/*w  w w . j  a va  2s.com*/
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:RowLayoutRowData.java

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

    RowLayout rowLayout = new RowLayout();
    shell.setLayout(rowLayout);/*w  ww.j  av a  2 s .  c o  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");
    list.setLayoutData(new RowData(100, 35));

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Drawing Example");

    Canvas canvas = new Canvas(shell, SWT.NONE);
    canvas.setSize(150, 150);/*w  ww .jav  a2 s  .c o  m*/
    canvas.setLocation(20, 20);
    shell.open();
    shell.setSize(200, 220);

    GC gc = new GC(canvas);
    gc.drawRectangle(10, 10, 40, 45);
    gc.drawOval(65, 10, 30, 35);
    gc.drawLine(130, 10, 90, 80);
    gc.drawPolygon(new int[] { 20, 70, 45, 90, 70, 70 });
    gc.drawPolyline(new int[] { 10, 120, 70, 100, 100, 130, 130, 75 });
    gc.dispose();

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

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

    styledText.addExtendedModifyListener(new ExtendedModifyListener() {
        public void modifyText(ExtendedModifyEvent event) {
            System.out.println(event.start);
            System.out.println(event.length);
            System.out.println(event.replacedText);
        }// www. jav a2s  .c  o m
    });

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