List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:org.eclipse.swt.snippets.Snippet303.java
public static void main(String[] args) { final String SCRIPT = "document.onmousedown = function(e) {if (!e) {e = window.event;} if (e) {window.status = 'MOUSEDOWN: ' + e.clientX + ',' + e.clientY;}}"; Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 303"); shell.setLayout(new FillLayout()); final Browser browser; try {//w ww . ja v a 2 s.c om browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } browser.addProgressListener(ProgressListener.completedAdapter(event -> browser.execute(SCRIPT))); browser.addStatusTextListener(event -> { if (event.text.startsWith("MOUSEDOWN: ")) { System.out.println(event.text); browser.execute("window.status = '';"); } }); browser.setUrl("eclipse.org"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboReadOnlyCreate.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a read-only Combo Combo readOnly = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); readOnly.setItems(ITEMS);// www . j a v a2 s. c o m shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:CursorSetControl.java
public static void main(String[] args) { Display display = new Display(); Cursor cursor = new Cursor(display, SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.open();/*w ww . ja v a2s. com*/ final Button b = new Button(shell, 0); b.setBounds(10, 10, 200, 200); b.setCursor(cursor); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } cursor.dispose(); display.dispose(); }
From source file:ShellStates.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FillLayout()); shell.setMinimized(true);//from w ww .ja va 2s. c om shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:ShellSmallImage.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Image small = new Image(display, "yourFile.gif"); shell.setImage(small);/*from w w w .ja va 2s. c om*/ shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet121.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 121"); shell.setLayout(new FillLayout()); Text text = new Text(shell, SWT.SINGLE | SWT.BORDER); text.setEchoChar('*'); shell.pack();/*from www. j ava 2 s.c om*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet327.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 327"); shell.setLayout(new FillLayout()); final Browser browser; try {/* w w w . ja va 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; } browser.setText(createPage(0)); browser.addLocationListener(LocationListener.changingAdapter(event -> { String location = event.location; int index = location.indexOf(PREAMBLE); if (index != -1) { int pageNumber = Integer.valueOf(location.substring(index + PREAMBLE.length())).intValue(); browser.setText(createPage(pageNumber)); event.doit = false; } })); shell.setBounds(10, 10, 200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CaretImage.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open();// w w w. j ava2s .c o m Caret caret = new Caret(shell, SWT.NONE); Image image = new Image(display, "yourFile.gif"); caret.setLocation(10, 10); caret.setImage(image); caret.setVisible(true); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet326.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 326"); shell.setLayout(new GridLayout()); final Browser browser; try {/*from ww w.ja v 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; } browser.setLayoutData(new GridData(400, 400)); browser.setText(HTML); final Button button = new Button(shell, SWT.PUSH); button.setText("Invoke Browser.close()"); button.addListener(SWT.Selection, event -> { boolean result = browser.close(); System.out.println("was Browser disposed: " + result); if (result) { button.setEnabled(false); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet159.java
public static void main(String[] args) { final String newTitle = "New Value for Title"; Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 159"); shell.setLayout(new FillLayout()); final Browser browser; try {/*from w ww .java 2 s .c o m*/ browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } browser.addTitleListener(event -> { System.out.println("TitleEvent: " + event.title); shell.setText(event.title); }); browser.addProgressListener(ProgressListener.completedAdapter(event -> { /* Set HTML title tag using JavaScript and DOM when page has been loaded */ boolean result = browser.execute("document.title='" + newTitle + "'"); if (!result) { /* Script may fail or may not be supported on certain platforms. */ System.out.println("Script was not executed."); } })); /* Load an HTML document */ browser.setUrl("http://www.eclipse.org"); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }