List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:DrawRoundRectangle.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.drawRoundRectangle(10, 10, 200, 200, 30, 30); }//from w w w . j a v a2s . com }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.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 ww w .j a v a2 s. com*/ text.setSize(text.computeSize(width, height)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GridLayoutColumnNumber2.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 2;/* ww w . j ava2 s.c om*/ shell.setLayout(layout); 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"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ModifyListenerUsing.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 modify."); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent arg0) { System.out.println("Text modified"); }//from w w w. jav a2 s.co 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);/*w ww.jav a 2s . 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:TableRowSelectionRemove.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); final Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);/* w ww . jav a2s .c o m*/ for (int i = 0; i < 128; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } table.setSelection(2); table.remove(table.getSelectionIndices()); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DrawOval.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.drawOval(200, 100, 500, 400); }/*from ww w .j a v a 2 s . c om*/ }); canvas.redraw(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:HoverHelp.java
/** * Runs main program.//w w w.j ava 2 s . co m */ public static void main(String[] args) { Display display = new Display(); Shell shell = new HoverHelp().open(display); // Event loop while (shell != null && !shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // Cleanup display.dispose(); }
From source file:MainClass.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); PrintDialog dlg = new PrintDialog(shell); dlg.setScope(PrinterData.SELECTION); PrinterData printerData = dlg.open(); if (printerData != null) { System.out.println(printerData.printToFile); // Printer printer = new Printer(printerData); // Use printer . . . // printer.dispose(); }/*from w ww . jav a 2 s .c o m*/ while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TreeItemInsert.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Tree tree = new Tree(shell, SWT.BORDER | SWT.MULTI); tree.setSize(200, 200);//from w w w . j ava 2 s . c om for (int i = 0; i < 5; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); } TreeItem item = new TreeItem(tree, SWT.NONE, 1); item.setText("*** New Item ***"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }