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:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION); for (int i = 0; i < 5; i++) { TableColumn column = new TableColumn(table, SWT.NONE); }// ww w . j a v a 2 s .com for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); for (int j = 0; j < 5; j++) { item.setText(j, "Row " + i + ", Column " + j); } } for (int i = 0, n = table.getColumnCount(); i < n; i++) { table.getColumn(i).pack(); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet57.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 57"); final ProgressBar bar = new ProgressBar(shell, SWT.SMOOTH); Rectangle clientArea = shell.getClientArea(); bar.setBounds(clientArea.x, clientArea.y, 200, 32); shell.open();// ww w . j av a2 s . c o m display.timerExec(100, new Runnable() { int i = 0; @Override public void run() { if (bar.isDisposed()) return; bar.setSelection(i++); if (i <= bar.getMaximum()) display.timerExec(100, this); } }); 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); // create a file menu and add an exit item final MenuItem file = new MenuItem(m, SWT.CASCADE); file.setText("File"); final Menu filemenu = new Menu(s, SWT.DROP_DOWN); file.setMenu(filemenu);/*from ww w. j a v a 2 s .c o m*/ final MenuItem openItem = new MenuItem(filemenu, SWT.PUSH); openItem.setText("Open"); final MenuItem separator = new MenuItem(filemenu, SWT.SEPARATOR); final 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:RowLayoutMargin.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.marginLeft = 20;/*from w w w.ja v a 2 s. co m*/ rowLayout.marginRight = 20; rowLayout.marginTop = 20; rowLayout.marginBottom = 20; 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:ComboTransferFocus.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) { if (e.detail == SWT.TRAVERSE_TAB_NEXT) { e.doit = false;//w w w. ja va2s. c o m e.detail = SWT.TRAVERSE_NONE; } } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet252.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 252"); shell.addListener(SWT.Paint, event -> { GC gc = event.gc;/*from w w w.ja v a2s . c om*/ gc.setLineAttributes(new LineAttributes(10, SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_SOLID, null, 0, 10)); gc.drawPolyline(new int[] { 50, 100, 50, 20, 60, 30, 50, 45 }); gc.setLineAttributes( new LineAttributes(1 / 2f, SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_DOT, null, 0, 10)); gc.drawPolyline(new int[] { 100, 100, 100, 20, 110, 30, 100, 45 }); }); shell.setSize(150, 150); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:StackLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); StackLayout layout = new StackLayout(); shell.setLayout(layout);//from ww w. j av a 2 s . c o m StackLayoutSelectionAdapter adapter = new StackLayoutSelectionAdapter(shell, layout); Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.addSelectionListener(adapter); Button two = new Button(shell, SWT.PUSH); two.setText("two"); two.addSelectionListener(adapter); Button three = new Button(shell, SWT.PUSH); three.setText("three"); three.addSelectionListener(adapter); layout.topControl = one; 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 av a 2 s . c o m final String RUN = "Press to Run"; final String IS_RUNNING = "Running..."; shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText(RUN); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { button.setText(IS_RUNNING); BusyIndicator.showWhile(button.getDisplay(), new SleepThread(1000)); button.setText(RUN); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:LineCapsSetting.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { int x = 20, y = 20, w = 120, h = 60; GC gc = event.gc;/* w ww . j a v a 2s.c o m*/ gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); gc.setLineWidth(10); int[] caps = { SWT.CAP_FLAT, SWT.CAP_ROUND, SWT.CAP_SQUARE }; for (int i = 0; i < caps.length; i++) { gc.setLineCap(caps[i]); gc.drawLine(x, y, x + w, y); y += 20; } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ImageGrayScale.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, "yourFile.gif"); Image disable = new Image(display, image, SWT.IMAGE_GRAY); e.gc.drawImage(disable, 10, 10); e.gc.drawImage(image, 10, 50); image.dispose();//from ww w .ja v a 2 s. c o m disable.dispose(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }