home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 July / Chip_1998-07_cd.bin / zkuste / JBuilder / BDK / Win / bdk_sep97.exe / _SETUP.1 / ExplicitButtonBeanInfo.java < prev    next >
Encoding:
Java Source  |  1997-09-10  |  2.4 KB  |  87 lines

  1. package sunw.demo.buttons;
  2.  
  3. import java.beans.*;
  4.  
  5.  
  6. /**
  7.  * BeanInfo for an ExplicitButton.
  8.  * 
  9.  * @see sunw.demo.buttons.ExplicitButton
  10.  */
  11. public class ExplicitButtonBeanInfo extends SimpleBeanInfo {
  12.  
  13.     public PropertyDescriptor[] getPropertyDescriptors() {
  14.         try {
  15.             PropertyDescriptor background =
  16.             new PropertyDescriptor("background", beanClass);
  17.         PropertyDescriptor foreground =
  18.             new PropertyDescriptor("foreground", beanClass);
  19.         PropertyDescriptor font =
  20.             new PropertyDescriptor("font", beanClass);
  21.             PropertyDescriptor label =
  22.             new PropertyDescriptor("label", beanClass);
  23.  
  24.             background.setBound(true);
  25.             foreground.setBound(true);
  26.             font.setBound(true);
  27.             label.setBound(true);
  28.  
  29.             PropertyDescriptor rv[] = {background, foreground, font, label};
  30.             return rv;
  31.         } catch (IntrospectionException e) {
  32.             throw new Error(e.toString());
  33.         }
  34.     }
  35.  
  36.  
  37.     public int getDefaultPropertyIndex() {
  38.     // the index for the "label" property
  39.         return 3; 
  40.     }
  41.  
  42.  
  43.     public EventSetDescriptor[] getEventSetDescriptors() {
  44.         try {
  45.             EventSetDescriptor push = new EventSetDescriptor(beanClass, 
  46.                     "actionPerformed",
  47.             java.awt.event.ActionListener.class,
  48.             "actionPerformed");
  49.  
  50.             EventSetDescriptor changed = new EventSetDescriptor(beanClass,
  51.             "propertyChange",
  52.             java.beans.PropertyChangeListener.class,
  53.             "propertyChange");
  54.  
  55.             push.setDisplayName("button push");
  56.             changed.setDisplayName("bound property change");
  57.     
  58.             EventSetDescriptor[] rv = { push, changed};
  59.             return rv;
  60.         } catch (IntrospectionException e) {
  61.             throw new Error(e.toString());
  62.         }
  63.     }
  64.  
  65.     public BeanDescriptor getBeanDescriptor() {
  66.         return new BeanDescriptor(beanClass, customizerClass);
  67.     }
  68.  
  69.     public java.awt.Image getIcon(int iconKind) {
  70.     if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  71.         iconKind == BeanInfo.ICON_COLOR_16x16 ) {
  72.         java.awt.Image img = loadImage("ExplicitButtonIcon16.gif");
  73.         return img;
  74.     }
  75.     if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  76.         iconKind == BeanInfo.ICON_COLOR_32x32 ) {
  77.         java.awt.Image img = loadImage("ExplicitButtonIcon32.gif");
  78.         return img;
  79.     }
  80.     return null;
  81.     }
  82.  
  83.     private final static Class beanClass = ExplicitButton.class;
  84.     private final static Class customizerClass = OurButtonCustomizer.class;
  85. }
  86.  
  87.