net.sf.jga.swing
Class GenericActionListener

java.lang.Object
  extended by net.sf.jga.swing.GenericActionListener
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class GenericActionListener
extends java.lang.Object
implements java.awt.event.ActionListener

Listener that will execute a given functor on every action event.

Copyright © 2004-2005 David A. Hall

Author:
David A. Hall

Constructor Summary
GenericActionListener(UnaryFunctor<java.awt.event.ActionEvent,?> fn)
          Builds an action listener that executes the given functor for every action event it receives.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          Passes the action event to the functor given at construction.
static
<T> GenericActionListener
buildEventListener(java.lang.Class<T> type, T object, java.lang.String methodName)
          Builds a listener that passes each action event it receives to the given method.
static
<T> GenericActionListener
buildListener(java.lang.Class<T> type, T object, java.lang.String methodName)
          Builds a listener invokes the given no-arg method every time an action event fires.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericActionListener

public GenericActionListener(UnaryFunctor<java.awt.event.ActionEvent,?> fn)
Builds an action listener that executes the given functor for every action event it receives.

Method Detail

buildListener

public static <T> GenericActionListener buildListener(java.lang.Class<T> type,
                                                      T object,
                                                      java.lang.String methodName)
Builds a listener invokes the given no-arg method every time an action event fires.


buildEventListener

public static <T> GenericActionListener buildEventListener(java.lang.Class<T> type,
                                                           T object,
                                                           java.lang.String methodName)
Builds a listener that passes each action event it receives to the given method.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
Passes the action event to the functor given at construction. The result of the functor, if any, is discareded.

Specified by:
actionPerformed in interface java.awt.event.ActionListener


Copyright © 2002-2006 David A. Hall. All Rights Reserved.