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:TableItemGetIndex.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200);//from ww w . j a v a 2s. c om for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } TableItem item = new TableItem(table, SWT.NONE, 5); item.setText(" New Item "); System.out.println(table.indexOf(item)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:SashFormOri.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); // Fill the parent window with the buttons and sash shell.setLayout(new FillLayout()); // Create the SashForm and the buttons SashForm sashForm = new SashForm(shell, SWT.VERTICAL); new Button(sashForm, SWT.PUSH).setText("Left"); new Button(sashForm, SWT.PUSH).setText("Right"); sashForm.setOrientation(SWT.HORIZONTAL); shell.open();// ww w .j av a 2 s . c o m while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet260.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setText("WebKit"); final Browser browser; try {/*from w w w . ja v a2 s. c o m*/ browser = new Browser(shell, SWT.WEBKIT); } catch (SWTError e) { System.out.println("Could not instantiate Browser: " + e.getMessage()); display.dispose(); return; } shell.open(); browser.setUrl("https://webkit.org/"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ButtonSelection.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); for (int i = 0; i < 20; i++) { Button button = new Button(shell, SWT.TOGGLE); button.setText("B" + i); }/*from w w w.j ava 2s . c o m*/ Control[] children = shell.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; ((Button) child).setSelection(true); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.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 w ww . j ava 2s .co 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); }/*ww w. ja va2 s . c o m*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet100.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10, 10, 200, 200);//w w w . j a va 2s . com Text text = new Text(shell, SWT.MULTI); text.setBounds(10, 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: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()); }/* w ww.jav a 2 s . c o m*/ }); 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 w w w . j a v a 2 s. c o m*/ }); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:TabItemAddPushButton.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER | SWT.BOTTOM); for (int i = 0; i < 6; i++) { TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText("TabItem " + i); Button button = new Button(tabFolder, SWT.PUSH); button.setText("Page " + i); item.setControl(button);// ww w .j a v a2 s.c om } tabFolder.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }