FileDocCategorySizeDatePackage
GenericButtonAdapter.javaAPI DocExample2153Sun Jan 04 20:58:06 GMT 1998BeansBook.util

GenericButtonAdapter

public class GenericButtonAdapter extends Object implements ActionListener

Fields Summary
protected Object
theTarget
protected Class
theTargetClass
protected static final Class[]
paramClasses
protected Hashtable
mappingTable
Constructors Summary
public GenericButtonAdapter(Object target)

  
   // constructor
     
                  
   
      theTarget = target;
      theTargetClass = target.getClass();
   
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent evt)

      try
      {
         // invoke the registered method on the target
         Method mthd = (Method)mappingTable.get(evt.getSource());
         
         Object params[] = { evt };
         mthd.invoke(theTarget, params);
      }
      catch (IllegalAccessException e)
      {
         System.out.println(e);
      }
      catch (InvocationTargetException e)
      {
         System.out.println(e);
      }
   
public voidregisterActionEventHandler(java.awt.Button btn, java.lang.String methodName)

      Method mthd = theTargetClass.getMethod(methodName, paramClasses);
      btn.addActionListener(this);
      mappingTable.put(btn, mthd);