Created
November 26, 2013 11:37
-
-
Save BornRiot/7657003 to your computer and use it in GitHub Desktop.
Third portion of Java Bean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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