{
if (EventQueue.isDispatchThread())
{
// The getNextEventMethod() issues wait() when no
// event is available, so we don't need do explicitly wait().
AWTEvent ev = queue.getNextEvent();
// This mimics EventQueue.dispatchEvent(). We can't use
// EventQueue.dispatchEvent() directly, because it is
// protected, unfortunately.
if (ev instanceof ActiveEvent)
((ActiveEvent) ev).dispatch();
else if (ev.getSource() instanceof Component)
((Component) ev.getSource()).dispatchEvent(ev);
else if (ev.getSource() instanceof MenuComponent)
((MenuComponent) ev.getSource()).dispatchEvent(ev);
// Other events are ignored as per spec in
// EventQueue.dispatchEvent
}
else
{