Documentation

Annotations

The @BeanInfo and @PropertyDesc annotations make it very easy to specifying BeanInfo information directly in the custom component. Its no longer necessary to implement extra BeanInfo classes. This drastically reduces time and code needed to create BeanInfo information.

When using the JFormDesigner annotations, you have to add the library jfd-annotations.jar (from redist folder) to the build path of your project (necessary for the Java compiler). The documentation is in jfd-annotations-javadoc.zip. It is not necessary to distribute jfd-annotations.jar with your application.

The API documentation is also available here: doc.formdev.com/jfd-annotations/

@BeanInfo

This annotation can be used to specify additional information for constructing a BeanInfo class and its BeanDescriptor.

Example for specifying a description, an icon, property display names and flags, and property categories:

@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 for a container component that has a content pane:

@BeanInfo(isContainer=true, containerDelegate="getContentPane")
public class MyPanel extends JPanel { ... }

@PropertyDesc

This annotation can be used to specify additional information for constructing a PropertyDescriptor.

This annotation may be used in a @BeanInfo annotation (see @BeanInfo.properties()) or may be attached to property getter or setter methods. If the getter method of a property is annotated, then the setter method of the same property is not checked for this annotation.

Important: This annotation requires that the @BeanInfo annotation is specified for the bean class. Otherwise this annotation is ignored when specified at methods.

Example for attaching this annotation to a property getter method:

@PropertyDesc(displayName="magnitude (in %)", preferred=true)
public int getMagnitude() {
    return magnitude;
}

Example for specifying this annotation in a @BeanInfo annotation:

@BeanInfo(
    properties={
        @PropertyDesc(name="magnitude", displayName="magnitude (in %)", preferred=true)
    }
)
public class MyBean extends JCompoment { ... }

@DesignCreate

This annotation can be used to mark a static method that should be invoked by JFormDesigner to create instances of the bean, which are then used in the JFormDesigner Design view. The annotated method must be static, must not have parameters and must return the instance of created bean.

Example for using this annotation to initialize the bean with test data for the Design view:

public class MyBean extends JCompoment {
@DesignCreate
private static MyBean designCreate() { MyBean myBean = new MyBean(); myBean.setData( new SomeDummyDataForDesigning() ); return myBean; } public MyBean() { // ... } }