List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
From source file:ImageEmpty.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) { Image image = new Image(display, 300, 200); GC gc = new GC(image); gc.drawLine(10, 10, 200, 200); gc.dispose();//from w ww. j a v a2 s . c om e.gc.drawImage(image, 10, 10); image.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { 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);// ww w . java 2 s.c om 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 a va2s .c o 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 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 ava2 s . co m 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(); }
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();// w w w . j a v a 2 s . c o m } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:EventSelection.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()); Button button = new Button(shell, SWT.RIGHT); button.setText("text on the button"); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { System.out.println("selected"); }//ww w . j a va 2 s . c o m public void widgetDefaultSelected(SelectionEvent arg0) { } }); 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: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(); display.dispose();/* w w w. j a va 2 s . co m*/ }
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 ww w .j a va 2 s.co m 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: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 a v a2s . co 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:ComboAddItem.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 ww w.j a va2 s .c om combo.add("new"); 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(); }