Example usage for javax.swing Timer isRepeats

List of usage examples for javax.swing Timer isRepeats

Introduction

In this page you can find the example usage for javax.swing Timer isRepeats.

Prototype

public boolean isRepeats() 

Source Link

Document

Returns true (the default) if the Timer will send an action event to its listeners multiple times.

Usage

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTimer.java

@Override
public void start() {
    if (!started) {
        timer = new Timer(delay, e -> {
            Timer timerBefore = timer;

            onTimerAction();//from ww  w  .  j a va2s.  c om

            // if user didn't stop or restart timer
            if (timerBefore == timer && !timerBefore.isRepeats()) {
                stop();
            }
        });
        timer.setRepeats(repeating);
        timer.start();

        this.started = true;
    }
}