List of usage examples for java.beans EventSetDescriptor getAddListenerMethod
public synchronized Method getAddListenerMethod()
From source file:EventTracerTest.java
/** * Add a listener to the given event set * @param c a component//from w ww.ja v a2s.c o m * @param eventSet a descriptor of a listener interface */ public void addListener(Component c, EventSetDescriptor eventSet) { // make proxy object for this listener type and route all calls to the handler Object proxy = Proxy.newProxyInstance(null, new Class[] { eventSet.getListenerType() }, handler); // add the proxy as a listener to the component Method addListenerMethod = eventSet.getAddListenerMethod(); try { addListenerMethod.invoke(c, proxy); } catch (InvocationTargetException e) { } catch (IllegalAccessException e) { } // ok not to add listener if exception is thrown }