FileDocCategorySizeDatePackage
YesNoDialogBeanInfo.javaAPI DocExample4146Mon Sep 22 13:30:32 BST 1997oreilly.beans.yesno

YesNoDialogBeanInfo

public class YesNoDialogBeanInfo extends SimpleBeanInfo
The BeanInfo class for the YesNoDialog bean

Fields Summary
Constructors Summary
Methods Summary
public java.beans.BeanDescriptorgetBeanDescriptor()
Return a descriptor for the bean itself. It specifies a customizer for the bean class. We could also add a description string here

    return new BeanDescriptor(YesNoDialog.class, YesNoDialogCustomizer.class);
  
public intgetDefaultPropertyIndex()
The message property is most often customized; make it the default

 return 1; 
public java.awt.ImagegetIcon(int kind)
Return an icon for the bean. We should really check the kind argument to see what size icon the beanbox wants, but since we only have one icon to offer, we just return it and let the beanbox deal with it

    return loadImage("YesNoDialogIcon.gif");
  
public java.beans.MethodDescriptor[]getMethodDescriptors()
This method returns an array of method descriptors for the supported methods of a bean. This allows us to provide useful description strings, but it also allows us to filter out non-useful methods like wait() and notify() that the bean inherits and which might otherwise be displayed by the beanbox.

    try {
      MethodDescriptor[] methods = {
        method("display", "Pop up the dialog; make it visible")
      };
      return methods;
    }
    catch (Exception e) {
      return super.getMethodDescriptors();
    }
  
public java.beans.PropertyDescriptor[]getPropertyDescriptors()
This method returns an array of PropertyDescriptor objects that specify additional information about the properties supported by the bean. By explicitly specifying property descriptors, we are able to provide simple help strings for each property; these would not be available to the beanbox through simple introspection. We are also able to register special property editors for two of the properties

    try {
      PropertyDescriptor[] props = {
        property("title", "The string that appears in the dialog title bar"),
        property("message", "The string that appears in the dialog body"),
        property("yesLabel", "The label for the 'Yes' button, if any"),
        property("noLabel", "The label for the 'No' button, if any"),
        property("cancelLabel", "The label for the 'Cancel' button, if any"),
        property("alignment", "The alignment of the message text"),
        property("font", "The font to use for message and buttons"),
        property("background", "The background color for the dialog"),
        property("foreground", "The text color for message and buttons")
      };

      props[1].setPropertyEditorClass(YesNoDialogMessageEditor.class);
      props[5].setPropertyEditorClass(YesNoDialogAlignmentEditor.class);

      return props;
    }
    catch (IntrospectionException e) {return super.getPropertyDescriptors(); }
  
public static java.beans.MethodDescriptormethod(java.lang.String name, java.lang.String description)
This is a convenience method for creating MethodDescriptors. Note that it assumes we are talking about methods with no arguments

    Method m = YesNoDialog.class.getMethod(name, new Class[] {});
    MethodDescriptor md = new MethodDescriptor(m);
    md.setShortDescription(description);
    return md;
  
public static java.beans.PropertyDescriptorproperty(java.lang.String name, java.lang.String description)
This is a convenience routine for creating PropertyDescriptor objects

    PropertyDescriptor p = new PropertyDescriptor(name, YesNoDialog.class);
    p.setShortDescription(description);
    return p;