我不了解从javax.swing.event.EventListenerList docs摘录的这段代码的原理:
protected void fireFooXXX() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i]==FooListener.class) {
// Lazily create the event:
if (fooEvent == null)
fooEvent = new FooEvent(this);
((FooListener)listeners[i+1]).fooXXX(fooEvent);
}
}
}
事件触发是通过javax.swing.tree.DefaultTreeModel等方式完全实现的,因此显然我什么都没得到。
最佳答案