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

public static void main(String[] args) {
    final Display display = new Display();
    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) {

            e.gc.setFont(display.getSystemFont());

            e.gc.drawText(display.getSystemFont().getFontData()[0].getName(), 5, 5);
        }//from   ww w . j  a  v a  2 s .co  m
    });

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

From source file:Snippet100.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    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);
    text.setBounds(10, 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:SliderMinMaxValue.java

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

    // Create a horizontal Slider, accepting the defaults
    new Slider(shell, SWT.HORIZONTAL);

    // Create a vertical Slider and set its properties
    Slider slider = new Slider(shell, SWT.VERTICAL);
    slider.setMinimum(0);// w w  w.  j ava  2  s .co m
    slider.setMaximum(100);
    slider.setIncrement(5);
    slider.setPageIncrement(20);
    slider.setSelection(75);

    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 display = new Display();
    final Shell shell = new Shell(display);

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

    shell.setLayout(new FillLayout());

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

    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.setFont(new Font(display, "Helvetica", 18, SWT.NORMAL));
            e.gc.drawText("www.java2s.com", 0, 0);
        }
    });

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

From source file:TabItemSelection.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);
    for (int i = 0; i < 6; i++) {
        TabItem item = new TabItem(tabFolder, SWT.NONE);
        item.setText("TabItem " + i);
        Button button = new Button(tabFolder, SWT.PUSH);
        button.setText("Page " + i);
        item.setControl(button);//w  ww .  ja  v  a 2s.c  o m
    }
    tabFolder.setSelection(2);

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

From source file:CompositePaintListener.java

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

    final Composite composite = new Composite(shell, SWT.BORDER);
    composite.setSize(700, 600);/*from  w  w w .j  av  a2 s  .  c  o  m*/

    final Color red = display.getSystemColor(SWT.COLOR_RED);
    composite.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.setBackground(red);
            e.gc.fillOval(5, 5, 690, 590);
        }
    });

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

From source file:FormLayoutControlOffsetAttachment.java

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

    shell.setLayout(new FormLayout());

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

    Point size = button1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int offset = size.x / 2;

    FormData formData = new FormData();
    formData.left = new FormAttachment(50, -1 * offset);

    button1.setLayoutData(formData);//from  w w w  .  j a  va  2 s  .c om

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

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

From source file:StyledTextIndentAlignmentJustify.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
    styledText.setText(text);//  www  .ja  va  2 s . c o m
    styledText.setLineIndent(0, 1, 50);
    styledText.setLineAlignment(2, 1, SWT.CENTER);
    styledText.setLineJustify(4, 1, true);
    styledText.setLineAlignment(6, 1, SWT.RIGHT);
    styledText.setLineJustify(6, 1, true);

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

From source file:BrowserLocationListener.java

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

    Browser browser = new Browser(shell, SWT.NONE);
    browser.setBounds(5, 5, 600, 600);//  w ww .  ja  v  a 2s .c o  m

    browser.addLocationListener(new LocationListener() {
        public void changed(LocationEvent event) {
            if (event.top)
                System.out.println(event.location);
        }

        public void changing(LocationEvent event) {
        }
    });

    browser.setUrl("http://java2s.com");
    shell.open();

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

From source file:Snippet20.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    CoolBar bar = new CoolBar(shell, SWT.BORDER);
    for (int i = 0; i < 2; i++) {
        CoolItem item = new CoolItem(bar, SWT.NONE);
        Button button = new Button(bar, SWT.PUSH);
        button.setText("Button " + i);
        Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        item.setPreferredSize(item.computeSize(size.x, size.y));
        item.setControl(button);/*w w w .j  ava  2  s.  co  m*/
    }
    bar.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}