List of usage examples for org.eclipse.swt.widgets Display readAndDispatch
public boolean readAndDispatch()
true
if there is potentially more work to do, or false
if the caller can sleep until another event is placed on the event queue. From source file:TabListFocusTransfer.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Button b1 = new Button(shell, SWT.PUSH); b1.setText("1"); Button b2 = new Button(shell, SWT.RADIO); b2.setText("2"); Button b3 = new Button(shell, SWT.RADIO); b3.setText("3"); Button b4 = new Button(shell, SWT.RADIO); b4.setText("4"); Button b5 = new Button(shell, SWT.PUSH); b5.setText("5"); Control[] tabList1 = new Control[] { b2, b1, b3, b5, b4 }; shell.setTabList(tabList1);/* w w w. j a v a2 s .c om*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GCCreateFrom.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Canvas Example"); shell.setLayout(new FillLayout()); final Canvas canvas = new Canvas(shell, SWT.NONE); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = new GC(canvas); gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); gc.drawFocus(5, 5, 200, 10); gc.drawText("You can draw text directly on a canvas", 60, 60); gc.dispose();/* www . ja v a 2 s .co m*/ } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DialogEmptyDisplay.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP); final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new RowLayout()); dialog.pack();/*from w w w. jav a 2 s . c om*/ dialog.open(); // Move the dialog to the center of the top level shell. Rectangle shellBounds = shell.getBounds(); Point dialogSize = dialog.getSize(); dialog.setLocation(shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); // 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.Snippet100.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 100"); shell.setBounds(10, 10, 200, 200);// w w w .j a va 2s . c o m Text text = new Text(shell, SWT.MULTI); Rectangle clientArea = shell.getClientArea(); text.setBounds(clientArea.x + 10, clientArea.y + 10, 150, 150); Font initialFont = text.getFont(); FontData[] fontData = initialFont.getFontData(); for (int i = 0; i < fontData.length; i++) { fontData[i].setHeight(24); } Font newFont = new Font(display, fontData); text.setFont(newFont); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } newFont.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet173.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Main Window"); shell.setLayout(new FillLayout()); final Browser browser; try {/*from w ww .j av a 2 s.co m*/ browser = new Browser(shell, BROWSER_STYLE); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } initialize(display, browser); shell.open(); /* any website with popups */ browser.setUrl("http://www.popuptest.com/"); 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 Tabbed Shell Example"); final CoolBar bar = new CoolBar(s, SWT.BORDER); bar.setSize(280, 70);//from w w w .j a v a2 s . c o m bar.setLocation(0, 0); // final Image openIcon = new Image(d, "c:\\icons\\open.jpg"); final CoolItem openCoolItem = new CoolItem(bar, SWT.NONE); final Button openBtn = new Button(bar, SWT.PUSH); // openBtn.setImage(openIcon); openBtn.pack(); Point size = openBtn.getSize(); openCoolItem.setControl(openBtn); openCoolItem.setSize(openCoolItem.computeSize(size.x, size.y)); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ComboRemoveItems.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); String[] ITEMS = { "A", "B", "C", "D" }; final Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);//from w w w. j a va 2 s. com combo.remove(0); combo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { System.out.println(combo.getText()); } public void widgetDefaultSelected(SelectionEvent e) { System.out.println(combo.getText()); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:JavaViewer.java
public static void main(String[] args) { Display display = new Display(); JavaViewer example = new JavaViewer(); Shell shell = example.open(display); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();//from www . j a va2 s.co m display.dispose(); }
From source file:ComboSelect.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); String[] ITEMS = { "A", "B", "C", "D" }; final Combo combo = new Combo(shell, SWT.DROP_DOWN); combo.setItems(ITEMS);//from w ww . j av a2 s . c o m combo.select(2); combo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { System.out.println(combo.getText()); } public void widgetDefaultSelected(SelectionEvent e) { System.out.println(combo.getText()); } }); 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 2s. c om*/ MenuItem openItem = new MenuItem(filemenu, SWT.PUSH); openItem.setText("&Open"); openItem.setAccelerator(SWT.CTRL + 'O'); openItem.addSelectionListener(new 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(); }