List of usage examples for java.beans BeanInfo getEventSetDescriptors
EventSetDescriptor[] getEventSetDescriptors();
From source file:IntrospectorDemo.java
public static void main(String args[]) { try {/* w w w .java2s. c o m*/ Class c = Class.forName("Colors"); BeanInfo beanInfo = Introspector.getBeanInfo(c); System.out.println("Properties:"); PropertyDescriptor propertyDescriptor[] = beanInfo.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptor.length; i++) { System.out.println("\t" + propertyDescriptor[i].getName()); } System.out.println("Events:"); EventSetDescriptor eventSetDescriptor[] = beanInfo.getEventSetDescriptors(); for (int i = 0; i < eventSetDescriptor.length; i++) { System.out.println("\t" + eventSetDescriptor[i].getName()); } } catch (Exception e) { System.out.println("Exception caught. " + e); } }
From source file:EventTracerTest.java
/** * Adds event tracers for all events to which this component and its children can listen * @param c a component// w w w . j a va 2s. c o m */ public void add(Component c) { try { // get all events to which this component can listen BeanInfo info = Introspector.getBeanInfo(c.getClass()); EventSetDescriptor[] eventSets = info.getEventSetDescriptors(); for (EventSetDescriptor eventSet : eventSets) addListener(c, eventSet); } catch (IntrospectionException e) { } // ok not to add listeners if exception is thrown if (c instanceof Container) { // get all children and call add recursively for (Component comp : ((Container) c).getComponents()) add(comp); } }