List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:RowLayoutHorizontal.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout(SWT.HORIZONTAL)); new Button(shell, SWT.PUSH).setText("one"); new Button(shell, SWT.PUSH).setText("two"); new Button(shell, SWT.PUSH).setText("three"); new Button(shell, SWT.PUSH).setText("four"); new Button(shell, SWT.PUSH).setText("five"); new Button(shell, SWT.PUSH).setText("six"); new Button(shell, SWT.PUSH).setText("seven"); shell.open();//from www.j a v a2 s. c o m while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GCColorChange.java
public static void main(String[] args) { final Display display = new Display(); final 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.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); e.gc.drawText("I'm in blue!", 20, 20); }/*from w w w . j ava2s.com*/ }); 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(); // Create the main window Shell shell = new Shell(display); Text fahrenheit = new Text(shell, SWT.BORDER); fahrenheit.setData("Type a temperature in Fahrenheit"); fahrenheit.setBounds(20, 20, 100, 20); fahrenheit.addHelpListener(new HelpListener() { public void helpRequested(HelpEvent event) { System.out.println((String) event.widget.getData()); }//from www .j a va2s . c o m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet301.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 301"); FillLayout layout = new FillLayout(); layout.marginHeight = 10;// w ww .j a va 2s . co m layout.marginWidth = 10; shell.setLayout(layout); Table table = new Table(shell, SWT.BORDER | SWT.NO_SCROLL); for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StyledTextModifyListener.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent event) { System.out.println("Character Count: " + styledText.getCharCount()); }/*from ww w . j a va2s . co m*/ }); 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.Snippet81.java
public static void main(String[] args) { if (args.length == 0) { System.out.println("Usage: java Main <program id>"); return;/*from w ww. j a v a 2 s . c o m*/ } String progID = args[0]; Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 81"); OleFrame frame = new OleFrame(shell, SWT.NONE); OleControlSite site = null; OleAutomation auto = null; try { site = new OleControlSite(frame, SWT.NONE, progID); auto = new OleAutomation(site); } catch (SWTException ex) { System.out.println("Unable to open type library for " + progID); display.dispose(); return; } printTypeInfo(auto); auto.dispose(); shell.dispose(); display.dispose(); }
From source file:FileDialogMultipleFileNameSelection.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); FileDialog dlg = new FileDialog(shell, SWT.MULTI); Collection files = new ArrayList(); if (dlg.open() != null) { String[] names = dlg.getFileNames(); for (int i = 0, n = names.length; i < n; i++) { StringBuffer buf = new StringBuffer(dlg.getFilterPath()); if (buf.charAt(buf.length() - 1) != File.separatorChar) buf.append(File.separatorChar); buf.append(names[i]);//from ww w . j av a 2s .com files.add(buf.toString()); } } System.out.println(files); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet184.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 184"); Spinner spinner = new Spinner(shell, SWT.BORDER); spinner.setMinimum(0);// w w w .jav a2 s .c o m spinner.setMaximum(1000); spinner.setSelection(500); spinner.setIncrement(1); spinner.setPageIncrement(100); Rectangle clientArea = shell.getClientArea(); spinner.setLocation(clientArea.x, clientArea.y); spinner.pack(); 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 d = new Display(); Shell s = new Shell(d); s.setText("A Shell Menu Example"); Menu m = new Menu(s, SWT.BAR); MenuItem file = new MenuItem(m, SWT.CASCADE); file.setText("File"); Menu filemenu = new Menu(s, SWT.DROP_DOWN); file.setMenu(filemenu);/*from ww w.j a va 2 s . com*/ MenuItem openItem = new MenuItem(filemenu, SWT.PUSH); openItem.setText("Open"); MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH); exitItem.setText("Exit"); s.setMenuBar(m); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:PopupMenuAddTwoControls.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. ja va2s. 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(); }