Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Create two one shot timers (2000 ms)

import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class TimerOneShot2000 {   public static void main(String[] args) {     Display display = new Display();     Shell shell = new Shell(display);     shell.setSize(200, 200);     shell.open();     display.timerExec(2000, new Runnable() {       public void run() {         System.out.println("2000");       }     });     while (!shell.isDisposed()) {       if (!display.readAndDispatch())         display.sleep();     }     display.dispose();   } }