Suggested alternative to Timer component in a frame

Hi
a simple and dirty question: what’s the recommended alternative for a Timer component when working in an AbstractFrame?

For what I can see a frame misses the plumbing for attaching timers to it, so what?

I could write an infinite running background task and putting UI related code in the progress callback, but that’s a bit ugly/hacky …

Thx, Paolo

Hi,

The easiest way - just add Timer programmatically to the host screen of the frame:

public class TimerFrame extends AbstractFrame {
    @Inject
    protected ComponentsFactory componentsFactory;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        Timer timer = componentsFactory.createTimer();
        timer.setRepeating(true);
        timer.setDelay(5000);
        timer.addActionListener(t -> {
            showNotification("Demo time!");
        });
        timer.start();

        ((Window) getFrame()).addTimer(timer);
    }
}

:sweat: how could I’ve missed that, thx!