Annotation Type BeanInfo


  • @Target(TYPE)
    @Retention(RUNTIME)
    public @interface BeanInfo
    This annotation can be used to specify additional information for constructing a BeanInfo class and its BeanDescriptor.

    JFormDesigner first uses Introspector.getBeanInfo(Class) to construct a BeanInfo and then applies changes specified in annotations to copies of the BeanInfo, BeanDescriptor and PropertyDescriptors.

    Example:

     @BeanInfo(
         description="My Bean",
         icon="MyBean.gif",
         properties={
             @PropertyDesc(name="magnitude", displayName="magnitude (in %)", preferred=true)
             @PropertyDesc(name="enabled", expert=true)
         },
         categories={
             @Category(name="Sizes", properties={"preferredSize", "minimumSize", "maximumSize"}),
             @Category(name="Colors", properties={"background", "foreground"}),
         }
     )
     public class MyBean extends JCompoment { ... }
     
    Example:
     @BeanInfo(isContainer=true,containerDelegate="getContentPane")
     public class MyPanel extends JPanel { ... }
     
    • Element Detail

      • description

        String description
        Description of the JavaBean.

        Used in the JFormDesigner Palette to display descriptions of beans in tooltips.

        Default:
        ""
      • icon

        String icon
        Resource name of a 16x16 color icon of the JavaBean. If the name starts with "/", it is an absolute resource name. Otherwise it is relative to the package of the JavaBean.

        JFormDesigner uses beanClass.getResource(icon) to locate the icon file.

        Default:
        ""
      • customizer

        Class<? extends Customizer> customizer
        Specifies the bean's customizer. A customizer provides a complete GUI for customizing a target JavaBean. A customizer must implement Customizer and inherit from Component so it can be instantiated inside an dialog.
        Default:
        java.beans.Customizer.class
      • isContainer

        boolean isContainer
        Specifies whether a component is a container or not. A container can have child components and a layout manager.
        Default:
        false
      • containerDelegate

        String containerDelegate
        If components should be added to a descendant of a container, then it is possible to specify a method that returns the container for the children. JFrame.getContentPane() is an example for such a method. The value must be a String and specifies the name of a method that takes no parameters and returns a Container.
        Default:
        ""
      • properties

        PropertyDesc[] properties
        Specifies property descriptors. See PropertyDesc for details. Example:
         @BeanInfo(
             properties={
                 @PropertyDesc(name="magnitude", displayName="magnitude (in %)", preferred=true),
                 @PropertyDesc(name="enabled", expert=true)
             }
         )
         public class MyBean extends JCompoment { ... }
         
        This attribute can be used to modify property descriptors of super classes without overriding property getter or setter methods.
        Default:
        {}
      • persistenceConstructorProperties

        String[] persistenceConstructorProperties
        Specifies the property names for a DefaultPersistenceDelegate(String[]) used to persist an instance of the annotated class. The annotated class must have a constructor that accepts the given properties. Only necessary for classes that are not JavaBeans.

        Used by JFormDesigner to encode/decode the property value to XML.

        Example:

         @BeanInfo(persistenceConstructorProperties={"value1", "value2"})
         public class MyImmutablePropertyData {
             private final String value1;
             private final String value2;
             public MyImmutablePropertyData( String value1, String value2 ) {
                 this.value1 = value1;
                 this.value2 = value2;
             }
             public String getValue1() { return value1; }
             public String getValue2() { return value2; }
         }
         
        See Also:
        https://www.formdev.com/jformdesigner/doc/java-beans/#persistenceDelegate2
        Default:
        {}