public class InvocationEvent extends AWTEvent implements ActiveEvent
Runnable 当派出由AWT事件调度线程的
run()方法。这个类可以作为一个参考实现
ActiveEvent而不是宣布新的类定义
dispatch().
这个类的实例都放在EventQueue通过电话invokeLater和invokeAndWait。客户端代码可以利用这一点来写invokeLater 替换功能,invokeAndWait没有任何AWTEventListener对象编写特殊代码。
未指定的行为将如果任何特定的InvocationEvent实例的id参数不在INVOCATION_FIRST到INVOCATION_LAST范围造成的。
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
catchExceptions
设置为true,如果dispatch()捕获异常并将其存储在异常实例变量。
|
static int |
INVOCATION_DEFAULT
所有invocationevents默认ID。
|
static int |
INVOCATION_FIRST
标记调用事件标识的范围的第一个整数标识。
|
static int |
INVOCATION_LAST
标记调用事件标识的范围的最后一个整数标识。
|
protected Object |
notifier
(可能为空)的对象的notifyall()方法后将可立即调用。run()方法返回或抛出异常或处理后的事件。
|
protected Runnable |
runnable
可运行的run()方法会被调用。
|
ACTION_EVENT_MASK, ADJUSTMENT_EVENT_MASK, COMPONENT_EVENT_MASK, consumed, CONTAINER_EVENT_MASK, FOCUS_EVENT_MASK, HIERARCHY_BOUNDS_EVENT_MASK, HIERARCHY_EVENT_MASK, id, INPUT_METHOD_EVENT_MASK, INVOCATION_EVENT_MASK, ITEM_EVENT_MASK, KEY_EVENT_MASK, MOUSE_EVENT_MASK, MOUSE_MOTION_EVENT_MASK, MOUSE_WHEEL_EVENT_MASK, PAINT_EVENT_MASK, RESERVED_ID_MAX, TEXT_EVENT_MASK, WINDOW_EVENT_MASK, WINDOW_FOCUS_EVENT_MASK, WINDOW_STATE_EVENT_MASKsource| Modifier | Constructor and Description |
|---|---|
protected |
InvocationEvent(Object source, int id, Runnable runnable, Object notifier, boolean catchThrowables)
构建具有指定源和ID将执行Runnable的
run方法时,派一个
InvocationEvent。
|
|
InvocationEvent(Object source, Runnable runnable)
构建具有指定源将执行Runnable的
run方法时,派一个
InvocationEvent。
|
|
InvocationEvent(Object source, Runnable runnable, Object notifier, boolean catchThrowables)
构建具有指定源将执行Runnable的
run方法时,派一个
InvocationEvent。
|
|
InvocationEvent(Object source, Runnable runnable, Runnable listener, boolean catchThrowables)
构建具有指定源将执行Runnable的
run方法时,派一个
InvocationEvent。
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispatch()
执行Runnable的
run()方法通知通知(如果有)时,
run()返回或抛出异常。
|
异常 |
getException()
返回的任何例外而执行Runnable的
run() 方法了。
|
Throwable |
getThrowable()
返回的任何错误而执行了Runnable的
run() 方法。
|
long |
getWhen()
返回的时间戳,这件事发生的时候。
|
boolean |
isDispatched()
返回
true如果事件调度或调度时抛出任何异常,
false否则。
|
String |
paramString()
返回标识此事件的参数字符串。
|
getSourcepublic static final int INVOCATION_FIRST
public static final int INVOCATION_DEFAULT
public static final int INVOCATION_LAST
protected Runnable runnable
protected volatile Object notifier
isDispatched()
protected boolean catchExceptions
public InvocationEvent(Object source, Runnable runnable)
run方法时,派一个
InvocationEvent。
这是一个方便的构造函数。表格的InvocationEvent(source, runnable)调用的行为一样InvocationEvent(source, runnable, null, false)调用。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Object起源事件
runnable -
Runnable的
run方法将执行
IllegalArgumentException -如果
source是空的
EventObject.getSource(),
InvocationEvent(Object, Runnable, Object, boolean)
public InvocationEvent(Object source, Runnable runnable, Object notifier, boolean catchThrowables)
run方法时,派一个
InvocationEvent。如果通知是non-
null,
notifyAll()将呼吁后立即
run返回或抛出异常。
表格的InvocationEvent(source, runnable, notifier, catchThrowables)调用的行为一样InvocationEvent(source, InvocationEvent.INVOCATION_DEFAULT, runnable, notifier, catchThrowables)调用。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Object起源事件
runnable -
Runnable的
run方法将执行
notifier -
Object的
notifyAll方法将在
Runnable.run返回或抛出异常或处理后的事件被称为
catchThrowables -指定是否
dispatch应该抓住时间执行
Runnable的
run法时,还是应该宣传Throwables的eventdispatchthread的调度循环
IllegalArgumentException -如果
source是空的
EventObject.getSource(),
InvocationEvent(Object, int, Runnable, Object, boolean)
public InvocationEvent(Object source, Runnable runnable, Runnable listener, boolean catchThrowables)
run方法时,派一个
InvocationEvent。如果听众是non-
null,
listener.run()后将立即返回
run有称,抛出异常的情况或事件进行处理。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Object起源事件
runnable -
Runnable的
run方法将执行
listener -
Runnablerunnable的
run()方法将在
InvocationEvent被派遣或设置为
catchThrowables -指定是否
dispatch应该抓住时间执行
Runnable的
run法时,还是应该宣传Throwables的eventdispatchthread的调度循环
IllegalArgumentException -如果
source是空的
protected InvocationEvent(Object source, int id, Runnable runnable, Object notifier, boolean catchThrowables)
run方法时,派一个
InvocationEvent。如果通知是non-
null,
notifyAll将呼吁后立即
run返回或抛出异常。
该方法抛出一个IllegalArgumentException如果source是null。
source -
Object起源事件
id -整数表示事件的类型。在允许值的信息,看到
InvocationEvent类的描述
runnable -
Runnable的
run方法将执行
notifier -
Object的
notifyAll方法将在
Runnable.run返回或抛出异常或处理后的事件被称为
catchThrowables -指定是否
dispatch应该抓住时间执行
Runnable的
run法时,还是应该宣传Throwables的eventdispatchthread的调度循环
IllegalArgumentException -如果
source是空的
EventObject.getSource(),
AWTEvent.getID()
public void dispatch()
run()方法通知通知(如果有)时,
run()返回或抛出异常。
dispatch 接口
ActiveEvent
isDispatched()
public 异常 getException()
run() 方法了。
public Throwable getThrowable()
run() 方法。
public long getWhen()
public boolean isDispatched()
true如果事件调度或调度时抛出任何异常,
false否则。该方法应该被等待的线程调用
notifier.wait()方法。因为虚假唤醒是可能的(在
Object.wait()解释),这种方法应该被用在等待循环确保事件得到派遣:
而(!事件。isdispatched()){wait()通知;}如果等待线程醒来没有调度事件的
isDispatched()方法返回
false,和
while循环执行一次,因此,造成被唤醒的线程恢复等待模式。
如果notifier.notifyAll()之前等待的线程进入notifier.wait()方法的while环路确保等待线程不会进入notifier.wait()方法。否则,没有保证等待线程将永远被唤醒的等待。
true如果事件已出动,或任何异常被抛出的同时调度,
false否则
dispatch(),
notifier,
catchExceptions
public String paramString()
paramString 方法重写,继承类
AWTEvent
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.