Skip to content

Instantly share code, notes, and snippets.

@BornRiot
Created November 26, 2013 11:37
Show Gist options
  • Save BornRiot/7657003 to your computer and use it in GitHub Desktop.
Save BornRiot/7657003 to your computer and use it in GitHub Desktop.
Third portion of Java Bean
package sample;
//Show properties and events.
import java.awt.*;
import java.beans.*;
public class IntrospectorDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
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);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment