SwingTimer

Methods
13
Fields
None

Getting one

SwingTimer.new(…)

Methods

MethodReturnsDescription
start()()Start it: the listener first runs the initial delay from now. Nothing when already running.
stop()()Stop it: the listener does not run again until it is started, and a run it posted that has not started yet does not run.
restart()()Stop it and start it again: the next run is the initial delay from now. Called from the action, it lets the next expiry post another run ev…
isRunning()booleanWhether it is running.
setRepeats(boolean)()false: run once and stop. Set from the action of a repeating timer, the expiry already scheduled still runs.
isRepeats()booleanWhether it repeats (the default).
setDelay(number)()The delay between runs, ms, from the next rescheduling on: set from the action, it reaches the expiry after the next one. Negative is an er…
getDelay()numberThe delay between runs, ms.
setInitialDelay(number)()The delay before the first run after start, ms. Negative is an error.
getInitialDelay()numberThe delay before the first run, ms.
setCoalesce(boolean)()Whether expiries coalesce (the default): while a run it posted has not returned (it waits on a dialog, or has not started), an expiry posts…
isCoalesce()booleanThe coalesce flag.
new(number, any)SwingTimerA stopped timer that, once started, calls listener delay ms later and then every delay ms (the initial delay and the delay are both `…

Returned by

MethodReturnsDescription
SwingTimerClass.newSwingTimerA stopped timer that, once started, calls listener delay ms later and then every delay ms (the initial delay and the delay are both `…

Method details

start

start: (SwingTimer) -> ()

Start it: the listener first runs the initial delay from now. Nothing when already running.

stop

stop: (SwingTimer) -> ()

Stop it: the listener does not run again until it is started, and a run it posted that has not started yet does not run.

restart

restart: (SwingTimer) -> ()

Stop it and start it again: the next run is the initial delay from now. Called from the action, it lets the next expiry post another run even while this one waits on a dialog.

setRepeats

setRepeats: (SwingTimer, boolean) -> ()

false: run once and stop. Set from the action of a repeating timer, the expiry already scheduled still runs.

setDelay

setDelay: (SwingTimer, number) -> ()

The delay between runs, ms, from the next rescheduling on: set from the action, it reaches the expiry after the next one. Negative is an error.

setInitialDelay

setInitialDelay: (SwingTimer, number) -> ()

The delay before the first run after start, ms. Negative is an error.

setCoalesce

setCoalesce: (SwingTimer, boolean) -> ()

Whether expiries coalesce (the default): while a run it posted has not returned (it waits on a dialog, or has not started), an expiry posts nothing. false posts every expiry: runs stack up behind a busy cycle, and start while an earlier one waits on a dialog. An action that raises leaves a coalescing timer with a run that never returned, so it posts nothing more until stop() or restart().

new

new: (number, any) -> SwingTimer

A stopped timer that, once started, calls listener delay ms later and then every delay ms (the initial delay and the delay are both delay, it repeats and coalesces). listener is an ActionListener: a function, or a table whose actionPerformed(self, event) is called; either gets the ActionEvent, whose getSource() is this timer. A negative delay is IllegalArgumentException.