DynamicActionAdapterpublic class DynamicActionAdapter extends Object implements ActionListener
Fields Summary |
---|
Hashtable | actions |
Methods Summary |
---|
public void | actionPerformed(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 void | hookup(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 void | invokeReflectedMethod(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);
}
|
|