List of usage examples for org.eclipse.swt.widgets Display dispose
public void 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);// w ww.j a va2 s. c om s.setText("A RowLayout Example"); s.setLayout(new RowLayout()); final Text t = new Text(s, SWT.SINGLE | SWT.BORDER); final Button b = new Button(s, SWT.BORDER); final Button b1 = new Button(s, SWT.BORDER); b.setText("OK"); b1.setText("Cancel"); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:CheckBoxButtonExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(3, true)); // Create three checkboxes new Button(shell, SWT.CHECK).setText("Checkbox 1"); new Button(shell, SWT.CHECK).setText("Checkbox 2"); new Button(shell, SWT.CHECK).setText("Checkbox 3"); shell.pack();/*w ww .j ava 2 s . co m*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ProgressBarUpdateUIThread.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); ProgressBar bar = new ProgressBar(shell, SWT.SMOOTH); bar.setBounds(10, 10, 200, 32);//from w w w. j a v a 2s . com shell.open(); for (int i = 0; i <= bar.getMaximum(); i++) { try { Thread.sleep(100); } catch (Throwable th) { } bar.setSelection(i); } while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:TableScrollSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);/*from w w w.j a v a2 s .co m*/ for (int i = 0; i < 128; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } table.setSelection(95); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ToggleButtonExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(3, true)); // Create three toggle buttons new Button(shell, SWT.TOGGLE).setText("Toggle 1"); new Button(shell, SWT.TOGGLE).setText("Toggle 2"); new Button(shell, SWT.TOGGLE).setText("Toggle 3"); shell.pack();/*www . j a va2s .c om*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet51.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);//from w ww.ja v a2s . com for (int i = 0; i < 128; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } table.setTopIndex(95); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); final Shell shell = new Shell(display); DirectoryDialog dlg = new DirectoryDialog(shell); dlg.setFilterPath("c:/"); dlg.setText("SWT's DirectoryDialog"); dlg.setMessage("Select a directory"); String dir = dlg.open();/* ww w . ja v a2 s. c om*/ if (dir != null) { System.out.println(dir); } while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet52.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);//from w ww . j av a 2s. c o m for (int i = 0; i < 128; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } table.setSelection(95); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet330.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 330"); shell.setLayout(new GridLayout(BUTTONS_PER_ROW, true)); final Browser browser; try {//from w w w . jav a 2 s. co m browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } GridData data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = BUTTONS_PER_ROW; browser.setLayoutData(data); { Button setHeaders = new Button(shell, SWT.PUSH); setHeaders.setText("Send custom headers"); setHeaders.addListener(SWT.Selection, event -> browser.setUrl("http://www.ericgiguere.com/tools/http-header-viewer.html", null, new String[] { "User-agent: SWT Browser", "Custom-header: this is just a demo" })); } { Button postTextPlain = new Button(shell, SWT.PUSH); postTextPlain.setText("Post data as 'text/plain'"); postTextPlain.addListener(SWT.Selection, event -> browser.setUrl("http://httpbin.org/post", "Plain text passed as postData", new String[] { "content-type: text/plain" })); } { Button postTextPlainUtf8 = new Button(shell, SWT.PUSH); postTextPlainUtf8.setText("Post data as 'text/plain' and specify encoding."); postTextPlainUtf8.addListener(SWT.Selection, event -> browser.setUrl("http://httpbin.org/post", "Plain text passed as postData", new String[] { "content-type: text/plain; charset=UTF-8" })); } { Button postUrlEncoded = new Button(shell, SWT.PUSH); postUrlEncoded.setText("Post data with url encoding key=value"); postUrlEncoded.addListener(SWT.Selection, event -> browser.setUrl("http://httpbin.org/post", "MyKey1=MyValue1&MyKey2=MyValue2", new String[] { "content-type: application/x-www-form-urlencoded" })); } { Button postDataBugzilla = new Button(shell, SWT.PUSH); postDataBugzilla.setText("Send post data to bugzilla. url encoding is used as default"); postDataBugzilla.addListener(SWT.Selection, event -> browser.setUrl( "https://bugs.eclipse.org/bugs/buglist.cgi", "emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW&email1=platform-swt-inbox&emailtype1=substring", null)); } { Button postDataBugzillaLongQuery = new Button(shell, SWT.PUSH); postDataBugzillaLongQuery.setText("Send post data to bugzilla. Very slow response"); postDataBugzillaLongQuery.addListener(SWT.Selection, event -> browser.setUrl("https://bugs.eclipse.org/bugs/buglist.cgi", "emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW", null)); } shell.setSize(1000, 1000); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:InputDialog.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); InputDialog dlg = new InputDialog(shell); String input = dlg.open();//from ww w. j a v a2 s. c o m if (input != null) { // User clicked OK; set the text into the label System.out.println(input); } while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }