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:org.eclipse.swt.snippets.Snippet173.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Main Window"); shell.setLayout(new FillLayout()); Browser browser = new Browser(shell, SWT.NONE); initialize(display, browser);/*from ww w. ja va 2 s. c o m*/ shell.open(); /* any website with popups */ browser.setUrl("http://www.cnn.com"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet44.java
public static void main(String[] args) { Display display = new Display(); final Cursor cursor = new Cursor(display, SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.open();//from ww w . j a v a2 s . c om final Button b = new Button(shell, 0); b.setBounds(10, 10, 200, 200); b.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { b.setCursor(cursor); } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } cursor.dispose(); display.dispose(); }
From source file:TrackerMouseDown.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.open();// w w w . java2 s.c o m shell.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event e) { Tracker tracker = new Tracker(shell, SWT.NONE); tracker.setRectangles(new Rectangle[] { new Rectangle(e.x, e.y, 100, 100), }); tracker.open(); } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:WidgetBoundsSetting.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10, 10, 200, 200);//from w w w. j av a 2 s . c o m Button button1 = new Button(shell, SWT.PUSH); button1.setText("&Typical button"); button1.setBounds(10, 10, 180, 30); Button button2 = new Button(shell, SWT.PUSH); button2.setText("&Overidden button"); button2.setBounds(10, 50, 180, 30); 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 GridLayout()); ProgressBar pb1 = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH); pb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); pb1.setMinimum(0);/* w w w.ja v a 2s . c o m*/ pb1.setMaximum(30); new LongRunningOperation(display, pb1).start(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:FormLayoutFormDataWidthHeight.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); FormData formData = new FormData(); formData.width = 100;/*from www.ja v a2 s . co m*/ formData.height = 200; Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(formData); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:StyledTextClearKeyBinding.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER); styledText.setText("12345"); styledText.setKeyBinding('i' | SWT.ALT, ST.TOGGLE_OVERWRITE); //clear/* w w w.j a v a 2s . c o m*/ styledText.setKeyBinding('i' | SWT.ALT, SWT.NULL); styledText.setBounds(10, 10, 100, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet120.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(200, 200);//from w w w .ja v a 2 s. co m Monitor primary = display.getPrimaryMonitor(); Rectangle bounds = primary.getBounds(); Rectangle rect = shell.getBounds(); int x = bounds.x + (bounds.width - rect.width) / 2; int y = bounds.y + (bounds.height - rect.height) / 2; shell.setLocation(x, y); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DrawTextSWT.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.drawString("www.java2s.com", 5, 5); }//from ww w . j av a 2 s . c o m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:StyledTextPaint.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10, 10, 250, 250);/* ww w . ja v a 2s . c om*/ final StyledText text = new StyledText(shell, SWT.NONE); text.setBounds(10, 10, 200, 200); text.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { System.out.println("paint"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }