EventUtils¶
- public class org.apache.commons.lang3.event.EventUtils[source]¶
Provides some useful event-based utility methods.
- Since:
3.0
Constructors¶
Deprecated. Make private in 4.0. |
- @Deprecated public EventUtils()[source]¶
Deprecated: TODO Make private in 4.0.
Make private in 4.0.
Methods¶
Adds an event listener to the specified source. |
|
Binds an event listener to a specific method on a specific object. |
- public static <L> void addEventListener(Object eventSource, Class<L> listenerType, L listener)[source]¶
Adds an event listener to the specified source. This looks for an “add” method corresponding to the event type (addActionListener, for example).
- Parameters:
eventSource – The event source.
listenerType – The event listener type.
listener – The listener.
- Type parameters:
<L> – the event listener type.
- Throws:
java.lang.IllegalArgumentException – Thrown if the object doesn’t support the listener type.
- public static <L> void bindEventsToMethod(Object target, String methodName, Object eventSource, Class<L> listenerType, String... eventTypes)[source]¶
Binds an event listener to a specific method on a specific object.
- Type parameters:
<L> – the event listener type.
- Parameters:
target – The target object.
methodName – The name of the method to be called.
eventSource – The object which is generating events (JButton, JList, etc.).
listenerType – The listener interface (ActionListener.class, SelectionListener.class, etc.).
eventTypes – The event types (method names) from the listener interface (if none specified, all will be supported).