public class Alarm extends java.lang.Object implements Disposable
addRequest(java.lang.Runnable, int, boolean)
methods to schedule the requests.
Two requests scheduled with the same delay are executed sequentially, one after the other.
cancelAllRequests()
and cancelRequest(Runnable)
allow to cancel already scheduled requests.Modifier and Type | Class and Description |
---|---|
static class |
Alarm.ThreadToUse |
Disposable.Parent
Constructor and Description |
---|
Alarm()
Creates alarm that works in Swing thread
|
Alarm(Alarm.ThreadToUse threadToUse) |
Alarm(Alarm.ThreadToUse threadToUse,
Disposable parentDisposable) |
Alarm(Disposable parentDisposable)
Creates alarm that works in Swing thread
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addRequest(java.lang.Runnable request,
long delayMillis,
ModalityState modalityState) |
void |
addComponentRequest(java.lang.Runnable request,
int delayMillis) |
void |
addComponentRequest(java.lang.Runnable request,
long delayMillis) |
void |
addRequest(java.lang.Runnable request,
int delayMillis) |
void |
addRequest(java.lang.Runnable request,
int delay,
boolean runWithActiveFrameOnly) |
void |
addRequest(java.lang.Runnable request,
int delayMillis,
ModalityState modalityState) |
void |
addRequest(java.lang.Runnable request,
long delayMillis) |
void |
addRequest(java.lang.Runnable request,
long delayMillis,
ModalityState modalityState) |
protected void |
cancelAllAndAddRequest(java.lang.Runnable request,
int delayMillis,
ModalityState modalityState) |
int |
cancelAllRequests() |
boolean |
cancelRequest(java.lang.Runnable request) |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
void |
drainRequestsInTest() |
int |
getActiveRequestCount() |
protected java.util.List<java.lang.Runnable> |
getUnfinishedRequests() |
boolean |
isDisposed() |
boolean |
isEmpty() |
Alarm |
setActivationComponent(javax.swing.JComponent component) |
void |
waitForAllExecuted(long timeout,
java.util.concurrent.TimeUnit unit)
wait for all requests to start execution (i.e.
|
protected static final Logger LOG
public Alarm()
public Alarm(Disposable parentDisposable)
public Alarm(Alarm.ThreadToUse threadToUse)
public Alarm(Alarm.ThreadToUse threadToUse, Disposable parentDisposable)
public void dispose()
Disposable
dispose
in interface Disposable
public void addRequest(java.lang.Runnable request, int delay, boolean runWithActiveFrameOnly)
public void addRequest(java.lang.Runnable request, long delayMillis)
public void addRequest(java.lang.Runnable request, int delayMillis)
public void addComponentRequest(java.lang.Runnable request, int delayMillis)
public void addComponentRequest(java.lang.Runnable request, long delayMillis)
public void addRequest(java.lang.Runnable request, int delayMillis, ModalityState modalityState)
public void addRequest(java.lang.Runnable request, long delayMillis, ModalityState modalityState)
protected void cancelAllAndAddRequest(java.lang.Runnable request, int delayMillis, ModalityState modalityState)
protected void _addRequest(java.lang.Runnable request, long delayMillis, ModalityState modalityState)
public boolean cancelRequest(java.lang.Runnable request)
public int cancelAllRequests()
public void drainRequestsInTest()
protected java.util.List<java.lang.Runnable> getUnfinishedRequests()
public void waitForAllExecuted(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public int getActiveRequestCount()
public boolean isEmpty()
public Alarm setActivationComponent(javax.swing.JComponent component)
public boolean isDisposed()