List of usage examples for org.eclipse.swt.widgets Display dispose
public void dispose()
From source file:Snippet55.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text text = new Text(shell, SWT.BORDER); int columns = 10; GC gc = new GC(text); FontMetrics fm = gc.getFontMetrics(); int width = columns * fm.getAverageCharWidth(); int height = fm.getHeight(); gc.dispose();/*from w ww.j a v a2 s. c o m*/ text.setSize(text.computeSize(width, height)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FileDialogFileTypeExtensions.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); FileDialog dlg = new FileDialog(shell, SWT.OPEN); dlg.setFilterNames(new String[] { "OpenOffice.org Spreadsheet Files (*.sxc)", "Microsoft Excel Spreadsheet Files (*.xls)", "Comma Separated Values Files (*.csv)", "All Files (*.*)" }); dlg.setFilterExtensions(new String[] { "*.sxc", "*.xls", "*.csv", "*.*" }); String fileName = dlg.open(); if (fileName != null) { System.out.println(fileName); }/*from w ww.j a va 2 s . c o m*/ display.dispose(); }
From source file:Snippet44.java
public static void main(String[] args) { Display display = new Display(); final Cursor cursor = new Cursor(display, SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.open();// w w w .j av a 2 s . c o m final Button b = new Button(shell, 0); b.setBounds(10, 10, 200, 200); b.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { b.setCursor(cursor); } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } cursor.dispose(); display.dispose(); }
From source file:DrawTextSWT.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.drawString("www.java2s.com", 5, 5); }//www.j a v a2 s . c o m }); 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(); final Shell s = new Shell(d); s.setSize(250, 200);//from www .j a v a2 s. co m s.setText("A MouseListener Example"); final Button b = new Button(s, SWT.PUSH); b.setText("Push Me"); b.setBounds(20, 50, 55, 25); s.open(); b.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent e) { System.out.println(e.x); } }); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); final Shell shell = new Shell(display); Region region = new Region(); region.add(createCircle(50, 50, 50)); region.subtract(createCircle(50, 50, 20)); shell.setRegion(region);/*from w ww .j av a 2 s .com*/ shell.setSize(region.getBounds().width, region.getBounds().height); shell.setBackground(display.getSystemColor(SWT.COLOR_BLUE)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DrawStringLineTabSWT.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.drawString("www.\njava2s\t.com", 5, 5); }//from w w w. j av a 2 s .c om }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet265.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Media Player Example"); shell.setLayout(new FillLayout()); try {/*from w w w . j ava 2 s.c o m*/ OleFrame frame = new OleFrame(shell, SWT.NONE); clientSite = new OleClientSite(frame, SWT.NONE, "WMPlayer.OCX"); clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MouseEventExample.java
/** * The application entry point/*from www . j ava 2s.co m*/ * * @param args the command line arguments */ public static void main(String[] args) { // Create the window Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); shell.setSize(450, 200); shell.setText("Mouse Event Example"); // Create the listener MouseEventExample myMouseEventExample = new MouseEventExample(shell); // Display the window shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:VerifyListenerUsing.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("Type somthing to verify."); text.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent arg0) { System.out.println("verifying"); }/*w w w. j ava 2s . co m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }