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:MainButton.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Radio Buttons"); shell.pack();/*from w w w .jav a 2 s .co m*/ Button[] radios = new Button[3]; radios[0] = new Button(shell, SWT.RADIO); radios[0].setSelection(true); radios[0].setText("Choice 1"); radios[0].setBounds(10, 5, 75, 30); radios[1] = new Button(shell, SWT.RADIO); radios[1].setText("Choice 2"); radios[1].setBounds(10, 30, 75, 30); radios[2] = new Button(shell, SWT.RADIO); radios[2].setText("Choice 3"); radios[2].setBounds(10, 55, 75, 30); shell.open(); shell.pack(); 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.setSize(250, 250);/*from w w w.j a v a2 s. c o m*/ s.setText("A Slider Example"); final Slider slide = new Slider(s, SWT.HORIZONTAL); slide.setBounds(15, 50, 125, 15); slide.setMinimum(0); slide.setMaximum(100); slide.setIncrement(1); final Text t = new Text(s, SWT.BORDER); t.setBounds(115, 25, 25, 25); t.setText("0"); slide.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { t.setText(new Integer(slide.getSelection()).toString()); } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:ComboFindingItem.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);/* www. j a va 2 s .c om*/ System.out.println(combo.indexOf("B")); 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: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 . ja v a2s. com*/ 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:TableSelectionEvent.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); }/*w w w . j a va2 s .co m*/ table.setSize(100, 100); table.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; System.out.println(event.item + " " + string); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboSetItems.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 www. j av a 2 s .c o m*/ System.out.println(combo.getItemCount()); 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:Snippet114.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Tree tree = new Tree(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); for (int i = 0; i < 12; i++) { TreeItem item = new TreeItem(tree, SWT.NONE); item.setText("Item " + i); }/*from w ww. j a va2 s .c o m*/ tree.setSize(100, 100); tree.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; System.out.println(event.item + " " + string); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a List with a vertical scroll bar List list = new List(shell, SWT.V_SCROLL); // Add a bunch of items to it for (int i = 0; i < 500; i++) { list.add("A list item"); }/* w w w.j a va 2 s . c o m*/ // Scroll to the bottom list.select(list.getItemCount() - 1); list.showSelection(); // Get the scroll bar ScrollBar sb = list.getVerticalBar(); // Add one more item that shows the selection value list.add("Selection: " + sb.getSelection()); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ScrollBarExample.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create a List with a vertical scroll bar List list = new List(shell, SWT.V_SCROLL); // Add a bunch of items to it for (int i = 0; i < 500; i++) { list.add("A list item"); }/* w ww . j a va2 s . c o m*/ // Scroll to the bottom list.select(list.getItemCount() - 1); list.showSelection(); // Get the scroll bar ScrollBar sb = list.getVerticalBar(); // Add one more item that shows the selection value list.add("Selection: " + sb.getSelection()); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FocusEventInOut.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text t = new Text(shell, SWT.SINGLE | SWT.BORDER); t.setBounds(10, 85, 100, 32);/*from w w w .jav a 2 s . c o m*/ Text t2 = new Text(shell, SWT.SINGLE | SWT.BORDER); t2.setBounds(10, 25, 100, 32); t2.addListener(SWT.FocusIn, new Listener() { public void handleEvent(Event e) { System.out.println("focus in"); } }); t2.addListener(SWT.FocusOut, new Listener() { public void handleEvent(Event e) { System.out.println("focus out"); } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }