import java.beans.*; //=================================================================== // This BeanInfo class accompanies bean "CleanBean" // Its sole purpose is to explicitly specify the bean's properties. // In so doing it hides the inherited Canvas properties to leave // behind only the bean's intended test property: "soleProperty". //=================================================================== public class CleanBeanBeanInfo extends SimpleBeanInfo { private static Boolean T = Boolean.TRUE; // a very shortcut private static Boolean F = Boolean.FALSE; // a very shortcut // this array of Objects is used to initialize the // PropertyDescriptor array, in getPropertyDescriptors(). // object order: prop name, bean class, getter, setter, expert T/F private static Object pDescInits[][] = { {"foreground" ,"getForeground" ,"setForeground" ,T}, {"background" ,"getBackground" ,"setBackground" ,T}, {"font" ,"getFont" ,"setFont" ,T}, {"name" ,"getName" ,"setName" ,T}, {"soleProperty" ,"getSoleProperty" ,"setSoleProperty" ,F} }; // end of 2-dim array //------------------------------------------------------------------- // Overridden getPropertyDescriptors //------------------------------------------------------------------- public PropertyDescriptor[] getPropertyDescriptors() { PropertyDescriptor[] beanProps; // allocate array beanProps = new PropertyDescriptor[ pDescInits.length ]; // now fill array with PropertyDescriptor objects initialized from // static data for (int i=0; i < pDescInits.length; i++) { try { beanProps[i] = new PropertyDescriptor( (String) pDescInits[i][0], CleanBean.class, (String) pDescInits[i][1], (String) pDescInits[i][2]); } catch (IntrospectionException fatal) { System.err.println("CleanBeanBeanInfo getProps() is flawed!"); System.err.println(fatal); System.exit(10); } // additionally, set property expert status boolean expertStatus = ((Boolean)pDescInits[i][3]).booleanValue(); beanProps[i].setExpert(expertStatus); } // return array of PropertyDescriptors return beanProps; } } // End of Class CleanBeanBeanInfo