Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.user.client
Class Timer

    java.lang.Object
      com.google.gwt.user.client.Timer

    public abstract class Timer

extends java.lang.Object

A simplified, browser-safe timer class. This class serves the same purpose as java.util.Timer, but is simplified because of the single-threaded environment. To schedule a timer, simply create a subclass of it (overriding `run()`) and call `schedule(int)` or `scheduleRepeating(int)`.

### Example

>     public class TimerExample implements EntryPoint, ClickListener {

>       public void onModuleLoad() {
>         Button b = new Button("Click and wait 5 seconds");
>         b.addClickListener(this);

>         RootPanel.get().add(b);
>       }

>       public void onClick(Widget sender) {
>         // Create a new timer that calls Window.alert().
>         Timer t = new Timer() {
>           public void run() {
>             Window.alert("Nifty, eh?");
>           }
>         };

>         // Schedule the timer to run once in 5 seconds.
>         t.schedule(5000);
>       }
>     }

Constructor Summary
`Timer()`

Method Summary
`void` | `cancel()` Cancels this timer.
`abstract void` | `run()` This method will be called when a timer fires.
`void` | `schedule(int delayMillis)` Schedules a timer to elapse in the future.
`void` | `scheduleRepeating(int periodMillis)` Schedules a timer that elapses repeatedly.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Timer

    public Timer()

Method Detail

### cancel

    public void cancel()

  Cancels this timer.

### run

    public abstract void run()

  This method will be called when a timer fires. Override it to implement the timer's logic.

### schedule

    public void schedule(int delayMillis)

  Schedules a timer to elapse in the future.

  Parameters:
    `delayMillis` - how long to wait before the timer elapses, in milliseconds

### scheduleRepeating

    public void scheduleRepeating(int periodMillis)

  Schedules a timer that elapses repeatedly.

  Parameters:
    `periodMillis` - how long to wait before the timer elapses, in milliseconds, between each repetition

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD