public abstract class Event
extends java.lang.Object
所有事件需要添加一个名为 getHandlerList() 的静态方法,返回与getHandlers()
一样的HandlerList
.
译注:说明白点,您必须把以下代码复制到您的自定义事件:
private static final HandlerList handlers = new HandlerList(); public HandlerList getHandlers() { return handlers; } public static HandlerList getHandlerList() { return handlers; }
限定符和类型 | 类和说明 |
---|---|
static class |
Event.Result |
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getEventName()
获取这个事件的名称,默认情况下,他是事件的类的简短名称.
|
abstract HandlerList |
getHandlers() |
boolean |
isAsynchronous()
任何自定义事件应该不与其他事件同步,必须使用特定的构造器.这是对使用异步事件的一些警告(注意事项):
这个事件永远不会触发内部代码触发的同步事件.尝试这么做的结果会得到
IllegalStateException . |
public Event()
原文:The default constructor is defined for cleaner code. This constructor assumes the event is synchronous.
public Event(boolean isAsync)
原文:This constructor is used to explicitly declare an event as synchronous or asynchronous.
isAsync
- true则为异步事件public java.lang.String getEventName()
原文:Convenience method for providing a user-friendly identifier. By default, it is the event's class's simple name.
public abstract HandlerList getHandlers()
public final boolean isAsynchronous()
IllegalStateException
.原文:Any custom event that should not by synchronized with other events must use the specific constructor. These are the caveats of using an asynchronous event:
IllegalStateException
.