List of usage examples for org.eclipse.swt.widgets Display sleep
public boolean sleep()
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 ww w . ja v a 2s . c o 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: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 .j a va2 s . co m 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 av a 2s.c om*/ 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: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);//from w w w .j av a2 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: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 w w w. jav 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 www . ja v a 2 s .com 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) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);//from www . j a v a 2 s .com shell.setLayout(new RowLayout()); Button button = new Button(shell, SWT.PUSH); button.setText("Push Me"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { PopupList list = new PopupList(shell); String[] OPTIONS = { "A", "B", "C" }; list.setItems(OPTIONS); String selected = list.open(shell.getBounds()); System.out.println(selected); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.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"); }//from w w w . ja va 2s.co 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(); }
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);/*www.j a va2 s . co m*/ s.setText("A Shell Composite Example"); GridLayout gl = new GridLayout(); gl.numColumns = 4; s.setLayout(gl); s.setLayout(gl); GridComposite gc = new GridComposite(s); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 4; gc.setLayoutData(gd); gd = new GridData(); RowComposite rc = new RowComposite(s); gd = new GridData(GridData.FILL_HORIZONTAL); rc.setLayoutData(gd); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }