Create two one shot timers (2000 ms) : SWT Timer « SWT « Java Tutorial






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();
  }
}








17.125.SWT Timer
17.125.1.Stop a repeating timer when a button is pressedStop a repeating timer when a button is pressed
17.125.2.Create one repeating timer
17.125.3.Create two one shot timers (2000 ms)