Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent evt)
try
{
// invoke the registered method on the target
Method m = (Method)mappingTable.get(evt.getSource());
Object[] params = { evt };
m.invoke(theTarget, params);
}
catch (InvocationTargetException e)
{
System.out.println(e);
}
catch (IllegalAccessException e)
{
System.out.println(e);
}
|
protected void | addMapping(java.awt.Button b, java.lang.String methodName)
if (mappingTable == null)
{
mappingTable = new Hashtable();
}
Method m = theTargetClass.getMethod(methodName, paramClasses);
mappingTable.put(b, m);
|
private void | readObject(java.io.ObjectInputStream stream)
// use default serialization for the non-transient members
try
{
stream.defaultReadObject();
// get the number of mappings
int cnt = stream.readInt();
// read the keys and values for the mapping
for (int i = 0; i < cnt; i++)
{
// read the button and method name
Button b = (Button)stream.readObject();
String name = (String)stream.readObject();
// add the mapping
addMapping(b, name);
}
}
catch (Exception e)
{
throw new IOException();
}
|
public void | registerActionEventHandler(java.awt.Button b, java.lang.String methodName)
addMapping(b, methodName);
b.addActionListener(this);
|
private void | writeObject(java.io.ObjectOutputStream stream)
// use default serialization for the non-transient members
stream.defaultWriteObject();
// store the number of mappings
int cnt = 0;
if (mappingTable == null)
{
// there are no mappings, so store a 0 count and return
stream.writeInt(cnt);
return;
}
// get a clone of the mapping table
Hashtable tempmapping;
synchronized (mappingTable)
{
tempmapping = (Hashtable)mappingTable.clone();
}
cnt = tempmapping.size();
stream.writeInt(cnt);
// get the enumerations of the keys and values
Enumeration keys = tempmapping.keys();
Enumeration vals = tempmapping.elements();
// store the keys and values
for (int i = 0; i < cnt; i++)
{
// get the button and associated method
Button b = (Button)keys.nextElement();
Method m = (Method)vals.nextElement();
// get the method name
String name = m.getName();
// store the button and method name
stream.writeObject(b);
stream.writeObject(name);
}
|