List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:StyledTextVerifyKeyListener.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addVerifyKeyListener(new VerifyKeyListener() { public void verifyKey(VerifyEvent e) { System.out.println(e.character); e.doit = false;//from w ww . j a v a 2 s . c om } }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet302.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 302"); FillLayout layout = new FillLayout(); layout.marginHeight = 10;/*w w w . j a v a 2 s . com*/ layout.marginWidth = 10; shell.setLayout(layout); Tree tree = new Tree(shell, SWT.BORDER | SWT.NO_SCROLL); for (int i = 0; i < 10; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TextEditor.java
public static void main(String[] args) { Display display = new Display(); TextEditor example = new TextEditor(); Shell shell = example.open(display); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();// ww w. j a v a 2s . c o m display.dispose(); }
From source file:DrawingProcessNewLine.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.drawText("www.\njava2s\t.com", 5, 5, true); e.gc.drawText("www.\njava2s\t.com", 5, 55, false); }/* w ww . ja va 2 s. c om*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.examples.controlexample.ControlExample.java
/** * Invokes as a standalone program.//from ww w. j a va 2 s. c om */ public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FillLayout()); ControlExample instance = new ControlExample(shell); shell.setText(getResourceString("window.title")); setShellSize(instance, shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } instance.dispose(); display.dispose(); }
From source file:SelectionStartEnd.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL); text.setBounds(10, 10, 400, 100);//from w w w . j a v a 2s.c om text.append("text text text text text text text text text text text text text "); shell.open(); text.setSelection(30, 38); System.out.println("selection=" + text.getSelection()); System.out.println("caret position=" + text.getCaretPosition()); System.out.println("caret location=" + text.getCaretLocation()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SashFormOri.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); // Fill the parent window with the buttons and sash shell.setLayout(new FillLayout()); // Create the SashForm and the buttons SashForm sashForm = new SashForm(shell, SWT.VERTICAL); new Button(sashForm, SWT.PUSH).setText("Left"); new Button(sashForm, SWT.PUSH).setText("Right"); sashForm.setOrientation(SWT.HORIZONTAL); shell.open();/*from w w w. ja v a 2 s .c om*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet187.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 187"); shell.setLayout(new FillLayout()); OleControlSite controlSite;//from w w w. j a va 2 s . c o m try { OleFrame frame = new OleFrame(shell, SWT.NONE); controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer"); controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } // IWebBrowser final OleAutomation webBrowser = new OleAutomation(controlSite); // When the document is loaded, access the document object for the new page // and evalute expression using Script. int DownloadComplete = 104; controlSite.addEventListener(DownloadComplete, new OleListener() { @Override public void handleEvent(OleEvent event) { int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" }); if (htmlDocumentID == null) return; Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; //IHTMLDocument2 OleAutomation htmlDocument = null; try { htmlDocument = pVarResult.getAutomation(); pVarResult.dispose(); int[] scriptID = htmlDocument.getIDsOfNames(new String[] { "Script" }); if (scriptID == null) return; pVarResult = htmlDocument.getProperty(scriptID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; OleAutomation htmlWindow = null; try { //IHTMLWindow2 htmlWindow = pVarResult.getAutomation(); pVarResult.dispose(); int[] evaluateID = htmlWindow.getIDsOfNames(new String[] { "evaluate" }); if (evaluateID == null) return; String expression = "5+Math.sin(9)"; Variant[] rgvarg = new Variant[] { new Variant(expression) }; pVarResult = htmlWindow.invoke(evaluateID[0], rgvarg, null); if (pVarResult == null || pVarResult.getType() == 0) return; System.out.println(expression + " =" + pVarResult.getString()); } finally { htmlWindow.dispose(); } } finally { htmlDocument.dispose(); } } }); // Navigate to a web site int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" }); Variant[] rgvarg = new Variant[] { new Variant( "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet187.html") }; int[] rgdispidNamedArgs = new int[] { ids[1] }; webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } //Remember to release OleAutomation Object webBrowser.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet52.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 52"); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); Rectangle clientArea = shell.getClientArea(); table.setBounds(clientArea.x, clientArea.y, 200, 200); for (int i = 0; i < 128; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }// w w w . ja v a2 s .com table.setSelection(95); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet40.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Composite c1 = new Composite(shell, SWT.BORDER); c1.setSize(100, 100);/*from ww w .j a v a2 s.c o m*/ Composite c2 = new Composite(shell, SWT.BORDER); c2.setBounds(100, 0, 100, 100); Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Popup"); c1.setMenu(menu); c2.setMenu(menu); shell.setMenu(menu); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }