Class Timer

java.lang.Object
vaadinx.swing.Timer
All Implemented Interfaces:
Serializable

public class Timer extends Object implements Serializable
Emulator for Timer. Emulator-only per D_timer_swingworker — no surrogate (Timer isn't a Component, no peer to back).

Backed by the shared per-session UiScheduler (a single-thread ScheduledExecutorService on a platform daemon thread). The scheduler thread does no user work — on fire it hops back to the session's live UI thread via EHelper.onSessionLiveUI(VaadinSession, Runnable), which resolves the current UI and enters EHelper.callSwing(Runnable) so the ActionEvent is delivered inside the R_callswing_envelope virtual-thread envelope. User listeners run under the session lock and can park on blocking dialogs.

The owning VaadinSession is captured at construction — not the UI. Session scope is what lets a running Timer survive an F5 @PreserveOnRefresh teleport (the old UI closes, a fresh one takes over): the scheduler outlives the refresh and each fire re-resolves the now-current UI. Constructing a Timer with no current session throws IllegalStateException. See UiScopedFeaturesF5Test.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • addActionListener

      public void addActionListener(ActionListener l)
    • removeActionListener

      public void removeActionListener(ActionListener l)
    • getActionListeners

      public ActionListener[] getActionListeners()
    • getListeners

      public <T extends EventListener> T[] getListeners(Class<T> listenerType)
    • getDelay

      public int getDelay()
    • setDelay

      public void setDelay(int delay)
      Throws:
      IllegalArgumentException - if delay < 0 (JDK-faithful).
    • getInitialDelay

      public int getInitialDelay()
    • setInitialDelay

      public void setInitialDelay(int initialDelay)
      Throws:
      IllegalArgumentException - if initialDelay < 0 (JDK-faithful).
    • isRepeats

      public boolean isRepeats()
    • setRepeats

      public void setRepeats(boolean repeats)
    • isCoalesce

      public boolean isCoalesce()
    • setCoalesce

      public void setCoalesce(boolean coalesce)
    • getActionCommand

      public String getActionCommand()
    • setActionCommand

      public void setActionCommand(String actionCommand)
    • setLogTimers

      public static void setLogTimers(boolean flag)
    • getLogTimers

      public static boolean getLogTimers()
    • isRunning

      public boolean isRunning()
    • start

      public void start()
      Starts the Timer. Safe to call when already running — JDK-faithful no-op.

      A started Timer holds the app open (AutoShutdown), so disposing the last window while it runs leaves the session alive — the status-bar-clock paper cut, reproduced (D_auto_shutdown).

    • stop

      public void stop()
      Stops the Timer. Pending fires already queued on the EDT are dropped on delivery (the EDT-side fire body re-checks running); fires that haven't yet reached the EDT are cancelled via future.cancel(false).
    • restart

      public void restart()