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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    final Sash sash = new Sash(shell, SWT.BORDER | SWT.VERTICAL);
    sash.setBounds(10, 10, 32, 100);//from w  ww. jav  a 2  s. com
    sash.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event e) {
            System.out.println("selection");
            sash.setBounds(e.x, e.y, e.width, e.height);
        }
    });
    shell.open();
    sash.setFocus();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:TextSelectionListener.java

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

    Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
    text.setText("some text");
    text.addListener(SWT.DefaultSelection, new Listener() {
        public void handleEvent(Event e) {
            System.out.println(e.widget + " - Default Selection");
        }//w ww . java  2 s  .c  om
    });

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

From source file:DrawOval.java

public static void main(String[] args) {
    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.drawOval(200, 100, 500, 400);
        }/*from  w  w w .  j av  a 2s .co  m*/
    });

    canvas.redraw();

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

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 199");
    shell.setLayout(new FillLayout());
    OleControlSite controlSite;/*from  w  w  w . ja  v a  2  s  .co  m*/
    try {
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        controlSite = new OleControlSite(frame, SWT.NONE, "Excel.Sheet");
        controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTError e) {
        System.out.println("Unable to open activeX control");
        display.dispose();
        return;
    }
    shell.open();

    OleAutomation excelSheet = new OleAutomation(controlSite);
    int[] dispIDs = excelSheet.getIDsOfNames(new String[] { "Application" });
    Variant pVarResult = excelSheet.getProperty(dispIDs[0]);
    OleAutomation application = pVarResult.getAutomation();
    pVarResult.dispose();
    excelSheet.dispose();

    int eventID = SheetSelectionChange;
    OleListener listener = new OleListener() {
        @Override
        public void handleEvent(OleEvent e) {
            System.out.println("selection has changed");
            Variant[] args = e.arguments;
            for (int i = 0; i < args.length; i++) {
                System.out.println(args[i]);
            }
        }
    };
    controlSite.addEventListener(application, IID_AppEvents, eventID, listener);

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

From source file:MainClass.java

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

    PrintDialog dlg = new PrintDialog(shell);

    dlg.setScope(PrinterData.SELECTION);

    PrinterData printerData = dlg.open();
    if (printerData != null) {

        System.out.println(printerData.printToFile);

        // Printer printer = new Printer(printerData);
        // Use printer . . .
        // printer.dispose();
    }/*from  w w  w.j a va 2s.  c om*/

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

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 18");
    ToolBar bar = new ToolBar(shell, SWT.BORDER);
    for (int i = 0; i < 8; i++) {
        ToolItem item = new ToolItem(bar, SWT.PUSH);
        item.setText("Item " + i);
    }/* w ww.  j  av a2 s . c  o m*/
    Rectangle clientArea = shell.getClientArea();
    bar.setLocation(clientArea.x, clientArea.y);
    bar.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:HelpListenerUsing.java

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

    Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
    text.setText("press F1 function to see the help message.");
    text.addHelpListener(new HelpListener() {

        public void helpRequested(HelpEvent arg0) {
            System.out.println("Help wanted");
        }/* w  ww  .  j  ava  2 s  .c  o  m*/
    });

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

From source file:HoverHelp.java

/**
 * Runs main program.//from w  ww  . j av  a 2 s.  c o m
 */
public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new HoverHelp().open(display);
    // Event loop
    while (shell != null && !shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    // Cleanup
    display.dispose();

}

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

public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 374");
    shell.setLayout(new FillLayout());
    shell.setText("Customize line vertical indent");

    StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL);
    text.setWordWrap(true);// w  ww. j av  a  2  s.  com
    text.setText("word1 word2 word3 word4");
    text.setLineVerticalIndent(0, 20);

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

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

public static void main(String[] args) {

    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 78");
    shell.setLayout(new FillLayout());
    final Label label1 = new Label(shell, SWT.BORDER);
    label1.setText("TEXT");
    final Label label2 = new Label(shell, SWT.BORDER);
    setDragDrop(label1);/*from  ww w  .  j a  v  a2  s . c  o  m*/
    setDragDrop(label2);
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}