I have a function to implement in a Java 1.5 Swing application. If a specific exception occurs during AWTEvent processing, I must open an alternative form, solve the problem, and continue processing the source event. When I rewrite an event into a component, nothing happens. When I click on an event in the event queue, nothing happens. I assume that there are some status fields in the event that mark it as processed, so the components do not pick it up. So far I can’t find a way to recreate the clone of the event. And the custom event will not help here, because I want the previous event to be processed.
In the swing application, the existing event queue is replaced by the internal queue.
private class ApplicationEventQueue extends EventQueue
{
private final ArrayList listeners=new ArrayList();
protected void initialize()
{
Toolkit.getDefaultToolkit().getSystemEventQueue().push(this);
}
.
.
.
}
, . , " ".
@Override
protected void dispatchEvent(AWTEvent event)
{
try
{
super.dispatchEvent(event);
if (peekEvent() != null && userEventDispatched)
{
raiseIdleEvent();
userEventDispatched = false;
}
else
{
int eventId = event.getID();
if (eventId == KeyEvent.KEY_TYPED || eventId == MouseEvent.MOUSE_CLICKED)
{
userEventDispatched = true;
}
}
}
catch (Throwable ex)
{
onError(ex);
}
}
- . , . - , , .
: onError , . , , , .
, , , , .
- ( ).
- , .
- , AWTEvent.
- , , .
- , .
, .
.
: . ( ) , . . . .
, , , , , , .