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) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);//from ww w . j av a 2 s .c om shell.setLayout(new FillLayout()); // Create a canvas Canvas canvas = new Canvas(shell, SWT.NONE); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setLineWidth(10); e.gc.drawLine(0, 0, 100, 100); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:TextBackground.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); StyledText text = new StyledText(shell, SWT.BORDER); text.setText("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); StyleRange style1 = new StyleRange(); style1.start = 0;/*from w ww.j a v a 2 s.c o m*/ style1.length = 10; style1.background = display.getSystemColor(SWT.COLOR_BLUE); text.setStyleRange(style1); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ComboSelectionListener.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Combo combo = new Combo(shell, SWT.NONE); combo.setItems(new String[] { "Press enter to select", "B-1", "C-1" }); combo.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { System.out.println("Combo"); }/* w w w. j a va 2 s.c o m*/ }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:LinkControlEventSelection.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Link link = new Link(shell, SWT.BORDER); link.setText("This a very simple <A href=\"htpp://www.java2s.com\">link</A> widget."); link.setSize(140, 40);/*from w w w . j av a 2 s . c o m*/ link.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { System.out.println("Selection: " + event.text); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MouseTrackAdapter.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.SHADOW_IN | SWT.CENTER); shell.setLayout(new GridLayout()); MouseTrackAdapter listener = new MouseEnterExitListener(); label.setText("Point your cursor here ..."); label.setBounds(30, 30, 200, 30);/*from w w w.j a va2 s. c o m*/ label.addMouseTrackListener(listener); shell.setSize(260, 120); shell.open(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:Snippet101.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 w w w. jav a 2 s .com*/ 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, 1); item.setText("*** New Item " + table.indexOf(item) + " ***"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GroupWithoutGroupingRadioButtons.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); // Create the second Group Group group2 = new Group(shell, SWT.NO_RADIO_GROUP); group2.setText("Who's your favorite?"); group2.setLayout(new RowLayout(SWT.VERTICAL)); new Button(group2, SWT.RADIO).setText("A"); new Button(group2, SWT.RADIO).setText("B"); new Button(group2, SWT.RADIO).setText("C"); shell.open();//from www.j a v a 2s . c o m while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:DrawFocusRectangle.java
public static void main(String[] args) { Display display = new Display(); 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(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawFocus(5, 5, 200, 10); }//from ww w . ja v a2s . c o m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet44.java
public static void main(String[] args) { Display display = new Display(); final Cursor cursor = display.getSystemCursor(SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.setText("Snippet 44"); shell.open();/*w ww . ja va 2s . com*/ final Button b = new Button(shell, 0); b.setText("Push to set cursor to hand"); Rectangle clientArea = shell.getClientArea(); b.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200); b.addListener(SWT.Selection, e -> b.setCursor(cursor)); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet41.java
public static void main(String[] args) { String string = "This is a string\nwith a new line."; Display display = new Display(); Shell shell = new Shell(display); shell.open();/*from w w w . j av a2 s . c o m*/ TabFolder folder = new TabFolder(shell, SWT.BORDER); folder.setSize(200, 200); TabItem item0 = new TabItem(folder, 0); item0.setToolTipText(string); ToolBar bar = new ToolBar(shell, SWT.BORDER); bar.setBounds(0, 200, 200, 64); ToolItem item1 = new ToolItem(bar, 0); item1.setToolTipText(string); shell.setToolTipText(string); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }