Class WTimer


public class WTimer extends WObject
A utility class which provides timer signals and single-shot timers.

To use a timer, create a WTimer instance, set the timer interval using setInterval() and connect a slot to the timeout signal. Then, start the timer using start(). An active timer may be cancelled at any time using stop().

By default, a timer will continue to generate events until you stop() it. To create a timer that will fire only once, use setSingleShot().

When connecting stateless slot implementations to the timeout signal, these stateless slot implementations will be used as for any other signal (when Ajax is available).

In clients without (enabled) JavaScript support, the minimum resolution of the timer is one second (1000 milli-seconds), and it is probably wise to use timers sparingly.

A WTimer is only usable inside of a JWt event loop. If you want to create a timer outside the JWt event loop, take a look at Timer.

  • Constructor Details

    • WTimer

      public WTimer()
      Construct a new timer with the given parent.
  • Method Details

    • getInterval

      public Duration getInterval()
      Returns the interval.
    • setInterval

      public void setInterval(Duration msec)
      Sets the interval.
    • isActive

      public boolean isActive()
      Returns if the timer is running.
    • isSingleShot

      public boolean isSingleShot()
      Is this timer set to fire only once.
    • setSingleShot

      public void setSingleShot(boolean singleShot)
      Configures this timer to fire only once.

      A Timer is by default not single shot, and will fire continuously, until it is stopped.

    • start

      public void start()
      Starts the timer.

      The timer will be isActive(), until either the interval has elapsed, after which the timeout signal is activated, or until stop() is called.

    • stop

      public void stop()
      Stops the timer.

      You may stop the timer during its timeout(), or cancel a running timer at any other time.

      See Also:
    • timeout

      public EventSignal1<WMouseEvent> timeout()
      Signal emitted when the timer timeouts.

      The WMouseEvent does not provide any meaningful information but is an implementation artefact.