Package org.apache.commons.lang3.event
Class EventUtils
- java.lang.Object
-
- org.apache.commons.lang3.event.EventUtils
-
public class EventUtils extends java.lang.Object
Provides some useful event-based utility methods.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description EventUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <L> void
addEventListener(java.lang.Object eventSource, java.lang.Class<L> listenerType, L listener)
Adds an event listener to the specified source.static <L> void
bindEventsToMethod(java.lang.Object target, java.lang.String methodName, java.lang.Object eventSource, java.lang.Class<L> listenerType, java.lang.String... eventTypes)
Binds an event listener to a specific method on a specific object.
-
-
-
Method Detail
-
addEventListener
public static <L> void addEventListener(java.lang.Object eventSource, java.lang.Class<L> listenerType, L listener)
Adds an event listener to the specified source. This looks for an "add" method corresponding to the event type (addActionListener, for example).- Type Parameters:
L
- the event listener type- Parameters:
eventSource
- the event sourcelistenerType
- the event listener typelistener
- the listener- Throws:
java.lang.IllegalArgumentException
- if the object doesn't support the listener type
-
bindEventsToMethod
public static <L> void bindEventsToMethod(java.lang.Object target, java.lang.String methodName, java.lang.Object eventSource, java.lang.Class<L> listenerType, java.lang.String... eventTypes)
Binds an event listener to a specific method on a specific object.- Type Parameters:
L
- the event listener type- Parameters:
target
- the target objectmethodName
- the name of the method to be calledeventSource
- 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)
-
-