public interface EventFilterable
EventPumps that implement this interface have the possibility
to filter AWT events before they are dispatched.
It is possible to retrieve the current EventPump used by Worker and
test if implements this interface; if so, a custom EventFilter may be provided.
EventPump pump = Worker.getEventPump();
if (pump instanceof EventFilterable)
{
// Save the old filter
EventFilter old = ((EventFilterable)pump).getEventFilter();
try
{
// Set the custom filter
((EventFilterable)pump).setEventFilter(new EventFilter()
{
public boolean accept(AWTEvent event)
{
// Do something with the event...
System.out.println("Event:" + event);
return true;
}
});
Worker.post(new Job()
{
public Object run()
{
// ...
}
});
}
finally
{
// Restore the old filter
((EventFilterable)pump).setEventFilter(old);
}
}
Absolute care must be used when filtering AWT events, as your Swing application may not work properly
if AWT events are not dispatched properly.| Modifier and Type | Method and Description |
|---|---|
EventFilter |
getEventFilter()
Returns the EventFilter
|
void |
setEventFilter(EventFilter filter)
Sets the EventFilter
|
void setEventFilter(EventFilter filter)
getEventFilter()EventFilter getEventFilter()
Copyright © 2002-2011. All Rights Reserved.