The event queue

EventDispatcher supports event queuing, that means, that events can be stored after they had been triggered and if you add a new listener after the event had been triggered, the event listener will receive the event right after you added it.

Again, the easiest way is to show you an example:

import net.schst.EventDispatcher.*;

EventDispatcher disp = EventDispatcher.getInstance();
disp.triggerEvent("onLogin", true);

EventListener debug = new DebugHandler();
disp.addListener("onLogin", debug);

Although the handler was added after the event has been triggered, EventDispatcher will pass the event to the handler, as it has been stored in the queue.

To avoid this behaviour, set the second parameter of the call to triggerEvent() to false, which tells EventDispatcher that the event should not be stored in the queue.