我不理解这段代码的基本原理,取自
javax.swing.event.EventListenerList文档:
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等等中以这种方式实施,所以显然我只是没有得到什么.