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:StyleRangeSetArray.java
License:asdf
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("asdfasdfasdfasdf12345678910234567890"); StyleRange[] ranges = new StyleRange[2]; ranges[0] = new StyleRange(0, 3, display.getSystemColor(SWT.COLOR_GREEN), null); ranges[1] = new StyleRange(3, 6, display.getSystemColor(SWT.COLOR_BLUE), null); styledText.setStyleRanges(ranges);// w ww . jav a 2s . co m styledText.setBounds(10, 10, 500, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutSpacing.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.spacing = 40;//from www . j a va2 s . c o m shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutWrap.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.wrap = false;/*from www .j a va 2 s .c o m*/ shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutJustify.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.justify = true;//from ww w. j ava2 s . c om shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:AccessibleListenerAdding.java
License:asdf
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Label label = new Label(shell, SWT.NONE); label.setText("asdf"); Accessible accessible = label.getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { super.getName(e); e.result = "Speak this instead of the text"; System.out.println("Accessible"); }/*from w ww .j a v a 2s . c om*/ }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ScollCompositeControl.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // this button is always 400 x 400. Scrollbars appear if the window is // resized to be // too small to show part of the button ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Button b1 = new Button(c1, SWT.PUSH); b1.setText("fixed size button"); b1.setSize(400, 400);// w ww . j a v a 2s. c o m c1.setContent(b1); shell.setSize(600, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet36.java
public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, 16, 16); Color color = display.getSystemColor(SWT.COLOR_RED); GC gc = new GC(image); gc.setBackground(color);/*from w ww.j a v a 2s. c o m*/ gc.fillRectangle(image.getBounds()); gc.dispose(); Shell shell = new Shell(display); ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.BORDER); for (int i = 0; i < 12; i++) { ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN); item.setImage(image); } toolBar.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); }
From source file:ComboTraverseListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Text text = new Text(shell, SWT.SINGLE | SWT.BORDER); text.setText("Press TAB"); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "Press enter to select", "B-1", "C-1" }); combo.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { System.out.println("keyTraversed"); }//from w ww.j ava 2 s. c om }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet213.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 213"); shell.setLayout(new FillLayout()); StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER); styledText.setText(text);/* ww w . j a va2 s . co m*/ styledText.setLineIndent(0, 1, 50); styledText.setLineAlignment(2, 1, SWT.CENTER); styledText.setLineJustify(4, 1, true); styledText.setLineAlignment(6, 1, SWT.RIGHT); styledText.setLineJustify(6, 1, true); shell.setSize(300, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RowLayoutType.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.type = SWT.VERTICAL;/*w w w.j a va2 s. c om*/ shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }