日期:2014-05-20 浏览次数:20799 次
import java.awt.event.*;
import java.lang.reflect.*;
public class Test {
public static void main(String[] args) throws Exception {
ActionListener ac = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("actionPeformed");
}
public void myMethod() {
System.out.println("myMethod");
}
};
ac.actionPerformed(null);
Method myMethod = ac.getClass().getMethod("myMethod", new Class[0]);
myMethod.invoke(ac);
}
}