FileDocCategorySizeDatePackage
DynamicActionAdapter.javaAPI DocExample1385Mon May 01 14:42:06 BST 2000None

DynamicActionAdapter

public class DynamicActionAdapter extends Object implements ActionListener

Fields Summary
Hashtable
actions
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

    Target target = (Target)actions.get( e.getSource(  ) );
    if ( target == null )
      throw new RuntimeException("unknown source");
    invokeReflectedMethod(target.object, target.methodName,
                          null, null);
  
public voidhookup(java.lang.Object sourceObject, java.lang.Object targetObject, java.lang.String targetMethod)


        
                         
    actions.put(sourceObject,
      new Target(targetObject, targetMethod));
    invokeReflectedMethod( sourceObject, "addActionListener",
      new Object[] {this}, new Class[] {ActionListener.class});
  
private voidinvokeReflectedMethod(java.lang.Object target, java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] argTypes)


    try {
      Method method =
        target.getClass(  ).getMethod( methodName, argTypes );
      method.invoke( target, args );
    }
    catch ( Exception e ) {
      throw new RuntimeException("invocation problem: "+e);
    }