1 /** 2 * Copyright (c) 2002-2005, Simone Bordet 3 * All rights reserved. 4 * 5 * This software is distributable under the BSD license. 6 * See the terms of the BSD license in the documentation provided with this software. 7 */ 8 9 package foxtrot.pumps; 10 11 /** 12 * {@link foxtrot.EventPump EventPumps} that implement this interface have the possibility 13 * to filter AWT events before they are dispatched. 14 * It is possible to retrieve the current EventPump used by {@link foxtrot.Worker Worker} and 15 * test if implements this interface; if so, a custom EventFilter may be provided. <br /> 16 * Example usage: 17 * <pre> 18 * EventPump pump = Worker.getEventPump(); 19 * if (pump instanceof EventFilterable) 20 * { 21 * // Save the old filter 22 * EventFilter old = ((EventFilterable)pump).getEventFilter(); 23 * 24 * try 25 * { 26 * // Set the custom filter 27 * ((EventFilterable)pump).setEventFilter(new EventFilter() 28 * { 29 * public boolean accept(AWTEvent event) 30 * { 31 * // Do something with the event... 32 * System.out.println("Event:" + event); 33 * return true; 34 * } 35 * }); 36 * 37 * Worker.post(new Job() 38 * { 39 * public Object run() 40 * { 41 * // ... 42 * } 43 * }); 44 * } 45 * finally 46 * { 47 * // Restore the old filter 48 * ((EventFilterable)pump).setEventFilter(old); 49 * } 50 * } 51 * </pre> 52 * 53 * Absolute care must be used when filtering AWT events, as your Swing application may not work properly 54 * if AWT events are not dispatched properly. 55 * @version $Revision: 1.3 $ 56 */ 57 public interface EventFilterable 58 { 59 /** 60 * Sets the EventFilter 61 * @see #getEventFilter 62 */ 63 public void setEventFilter(EventFilter filter); 64 65 /** 66 * Returns the EventFilter 67 * @see #setEventFilter 68 */ 69 public EventFilter getEventFilter(); 70 } 71