package jp.gr.javacons.industry.seminar.barmeter; import java.beans.*; import java.beans.SimpleBeanInfo; public class BarMeterBeanInfo extends SimpleBeanInfo { private final Class beanClass = BarMeter.class; public PropertyDescriptor[] getPropertyDescriptors(){ try{ PropertyDescriptor minimum = new PropertyDescriptor("minimum", beanClass); PropertyDescriptor maximum = new PropertyDescriptor("maximum", beanClass); PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass); PropertyDescriptor background = new PropertyDescriptor("background", beanClass); PropertyDescriptor[] pds = { minimum, maximum, foreground, background }; return pds; }catch (IntrospectionException e){ throw new Error(e.toString()); } } public MethodDescriptor[] getMethodDescriptors(){ try{ MethodDescriptor setValue = new MethodDescriptor(beanClass.getMethod("setValue", new Class[]{double.class})); MethodDescriptor[] mds = { setValue }; return mds; }catch (NoSuchMethodException e){ throw new Error(e.toString()); } } public BeanDescriptor getBeanDescriptor(){ BeanDescriptor bd = new BeanDescriptor(beanClass); bd.setValue("hidden-state", Boolean.TRUE); return bd; } public java.awt.Image getIcon(int nIconKind){ java.awt.Image img = null; if(nIconKind == BeanInfo.ICON_COLOR_16x16){ img = loadImage("barmeter16.gif"); }else if(nIconKind == BeanInfo.ICON_COLOR_32x32){ img = loadImage("barmeter32.gif"); } return img; } }