run() method on a Runnable
when dispatched by the AWT event dispatcher thread. This class can
be used as a reference implementation of ActiveEvent rather
than declaring a new class and defining dispatch().
Instances of this class are placed on the EventQueue by calls
to invokeLater and invokeAndWait. Client code
can use this fact to write replacement functions for invokeLater
and invokeAndWait without writing special-case code
in any AWTEventListener objects.
An unspecified behavior will be caused if the id parameter
of any particular InvocationEvent instance is not
in the range from INVOCATION_FIRST to INVOCATION_LAST.
java.awt.ActiveEvent , java.awt.EventQueue#invokeLater , java.awt.EventQueue#invokeAndWait , AWTEventListener
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | catchExceptions
Set to true if dispatch() catches Throwable and stores it in the exception instance variable. |
| private volatile boolean | |
| private Exception | |
| public static final int | INVOCATION_DEFAULT
The default id for all InvocationEvents. |
| public static final int | INVOCATION_FIRST
Marks the first integer id for the range of invocation event ids. |
| public static final int | INVOCATION_LAST
Marks the last integer id for the range of invocation event ids. |
| private final Runnable | |
| protected volatile Object | notifier
The (potentially null) Object whose notifyAll() method will be called immediately after the Runnable.run() method has returned or thrown an exception or after the event was disposed. |
| protected Runnable | runnable
The Runnable whose run() method will be called. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| private Throwable | |
| private long | when
The timestamp of when this event occurred. |
| Access | Constructor and Description |
|---|---|
| public | InvocationEvent(Object
The source, Runnable Object that originated the eventThe runnable)Runnable whose run()
method will be executedConstructs an |
| public | InvocationEvent(Object
The source, Runnable Object that originated
the eventThe runnable, Object Runnable whose
run() method will be
executedThe notifier, boolean Object whose notifyAll
method will be called after
Runnable.run has returned or
thrown an exception or after the event was
disposedSpecifies whether catchThrowables)dispatch
should catch Throwable when executing
the Runnable's run()
method, or should instead propagate those
Throwables to the EventDispatchThread's
dispatch loopConstructs an |
| public | InvocationEvent(Object
The source, Runnable Object that originated
the eventThe runnable, Runnable Runnable whose
run() method will be
executedThe listener, boolean Runnable whose
run() method will be called
after the InvocationEvent
was dispatched or disposedSpecifies whether catchThrowables)dispatch
should catch Throwable when executing
the Runnable's run()
method, or should instead propagate those
Throwables to the EventDispatchThread's
dispatch loopConstructs an |
| protected | InvocationEvent(Object
The source, int Object that originated
the eventAn integer indicating the type of event.
For information on allowable values, see
the class description for id, Runnable InvocationEventThe runnable, Object Runnable whose
run() method will be executedThe notifier, boolean Object whose notifyAll
method will be called after
Runnable.run has returned or
thrown an exception or after the event was
disposedSpecifies whether catchThrowables)dispatch
should catch Throwable when executing the
Runnable's run()
method, or should instead propagate those
Throwables to the EventDispatchThread's
dispatch loopConstructs an |
| private | InvocationEvent(Object source, int id, Runnable runnable, Object notifier, Runnable listener, boolean catchThrowables)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | dispatch()
Implements java. Executes the Runnable's |
| private void | finishedDispatching(boolean
true if the event was dispatched
false if the event was disposed dispatched)Called when the event was dispatched or disposed |
| public Exception | Returns: A reference to the Exception if one was thrown; null if no Exception was thrown or if this InvocationEvent does not catch exceptionsReturns any Exception caught while executing
the Runnable's |
| public Throwable | Returns: A reference to the Throwable if one was thrown; null if no Throwable was thrown or if this InvocationEvent does not catch ThrowablesReturns any Throwable caught while executing
the Runnable's |
| public long | |
| public boolean | Returns: true if the event has been dispatched, or any exception
has been thrown while dispatching, false otherwiseReturns |
| public String | Returns: A string identifying the event and its attributesOverrides java. Returns a parameter string identifying this event. |
| catchExceptions | back to summary |
|---|---|
| protected boolean catchExceptions Set to true if dispatch() catches Throwable and stores it in the exception instance variable. If false, Throwables are propagated up to the EventDispatchThread's dispatch loop. | |
| dispatched | back to summary |
|---|---|
private volatile boolean dispatched
| |
| exception | back to summary |
|---|---|
| private Exception exception | |
| INVOCATION_DEFAULT | back to summary |
|---|---|
| public static final int INVOCATION_DEFAULT The default id for all InvocationEvents. | |
| INVOCATION_FIRST | back to summary |
|---|---|
| public static final int INVOCATION_FIRST Marks the first integer id for the range of invocation event ids. | |
| INVOCATION_LAST | back to summary |
|---|---|
| public static final int INVOCATION_LAST Marks the last integer id for the range of invocation event ids. | |
| listener | back to summary |
|---|---|
private final Runnable listener
| |
| notifier | back to summary |
|---|---|
| protected volatile Object notifier The (potentially null) Object whose notifyAll() method will be called immediately after the Runnable.run() method has returned or thrown an exception or after the event was disposed.
| |
| runnable | back to summary |
|---|---|
| protected Runnable runnable The Runnable whose run() method will be called.
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.1 for interoperability. | |
| throwable | back to summary |
|---|---|
| private Throwable throwable | |
| when | back to summary |
|---|---|
| private long when The timestamp of when this event occurred.
| |
| InvocationEvent | back to summary |
|---|---|
| public InvocationEvent(Object source, Runnable runnable) Constructs an This is a convenience constructor. An invocation of the form
This method throws an
| |
| InvocationEvent | back to summary |
|---|---|
| public InvocationEvent(Object source, Runnable runnable, Object notifier, boolean catchThrowables) Constructs an An invocation of the form
This method throws an
| |
| InvocationEvent | back to summary |
|---|---|
| public InvocationEvent(Object source, Runnable runnable, Runnable listener, boolean catchThrowables) Constructs an This method throws an
| |
| InvocationEvent | back to summary |
|---|---|
| protected InvocationEvent(Object source, int id, Runnable runnable, Object notifier, boolean catchThrowables) Constructs an This method throws an
| |
| InvocationEvent | back to summary |
|---|---|
| private InvocationEvent(Object source, int id, Runnable runnable, Object notifier, Runnable listener, boolean catchThrowables) | |
| dispatch | back to summary |
|---|---|
| public void dispatch() Implements java. Executes the Runnable's
| |
| finishedDispatching | back to summary |
|---|---|
| private void finishedDispatching(boolean dispatched) Called when the event was dispatched or disposed
| |
| getException | back to summary |
|---|---|
| public Exception getException() Returns any Exception caught while executing
the Runnable's
| |
| getThrowable | back to summary |
|---|---|
| public Throwable getThrowable() Returns any Throwable caught while executing
the Runnable's
| |
| getWhen | back to summary |
|---|---|
| public long getWhen() Returns the timestamp of when this event occurred.
| |
| isDispatched | back to summary |
|---|---|
| public boolean isDispatched() Returns
while (!event.isDispatched()) {
notifier.wait();
}
If the waiting thread wakes up without dispatching the event,
the isDispatched() method returns false, and
the while loop executes once more, thus, causing
the awakened thread to revert to the waiting mode.
If the
| |
| paramString | back to summary |
|---|---|
| public String paramString() Overrides java. Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.
| |