Class WTimer
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
.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the interval.boolean
isActive()
Returns if the timer is running.boolean
Is this timer set to fire only once.void
setInterval
(Duration msec) Sets the interval.void
setSingleShot
(boolean singleShot) Configures this timer to fire only once.void
start()
Starts the timer.void
stop()
Stops the timer.timeout()
Signal emitted when the timer timeouts.Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
Constructor Details
-
WTimer
public WTimer()Construct a new timer with the given parent.
-
-
Method Details
-
getInterval
Returns the interval. -
setInterval
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 untilstop()
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
Signal emitted when the timer timeouts.The WMouseEvent does not provide any meaningful information but is an implementation artefact.
-