What is a Java Bean?
A Java Bean is a reusable software component that can be manipulated visually in a builder tool.
JavaBean (components) are self-contained, reusable software units that can be visually composed into composite components and applications. A bean is a Java class that:
JFormDesigner supports:
java.awt.Component
). JFormDesigner supports/uses
following classes/interfaces specified in the java.beans
package:
If you are writing BeanInfo
classes for your custom components, you can specify additional
information needed by JFormDesigner using the java.beans.FeatureDescriptor
extension mechanism.
You can also use BeanInfo Annotations to specify these attributes without the pain of implementing BeanInfo classes.
For examples using BeanInfo Annotations, example implementations of BeanInfo classes and PropertyEditors, take a look at the examples.
Following attributes are supported in BeanDescriptor:
Following attributes are supported in PropertyDescriptor:
Attribute Name | Description |
---|---|
category | Specifies the property category to which the
property
belongs. JFormDesigner adds the specified category to the Properties view. The value must be
a String .propDesc.setValue("category", "My Properties"); |
enumerationValues | Specifies
a list of valid property
values. The value must be a Object[] .
For each property value, the Object[]
must contain three
items:
|
extraPersistenceDelegates | Specifies a list of persistence delegates for
classes. The value must be a Object[] . For each class,
the Object[] must contain two items:
propDesc.setValue("extraPersistenceDelegates", new Object[]
{ MyClass2.class, new
MyClass2PersistenceDelegate(), }); |
imports | Specifies
one
or more class names for which import statements should be generated by
the Java code generator. This is useful if you don't use full qualified
class names in enumerationValues
or PropertyEditor.getJavaInitializationString() .
The value must be a String
or String[] .
E.g.propDesc.setValue("imports",
"com.mycompany.MyConstants"); |
notMultiSelection | Specifies whether the property is not shown
in the Properties
view when
multiple components are selected. The value must be a Boolean .
Default is false. E.g.propDesc.setValue("notMultiSelection", Boolean.TRUE); |
notNull | Specifies that a property can not set to null
in the Properties
view. If true, the Set Value to null command is disabled. The
value must be a Boolean .
Default is false. E.g.propDesc.setValue("notNull",
Boolean.TRUE); |
notRestoreDefault | Specifies that a property value can not restored
to the default in the Properties
view. If true, the Restore Default Value command is disabled.
The value must be a Boolean . Default is false. E.g.propDesc.setValue("notRestoreDefault", Boolean.TRUE); |
persistenceDelegate | Specifies an instance of a class,
which extends java.beans.PersistenceDelegate , that can be
used to persist an instance of a property value. E.g.propDesc.setValue("persistenceDelegate", |
readOnly | Specifies
that a property is
read-only in the Properties
view. The value must be a Boolean .
Default is false. E.g.propDesc.setValue("readOnly",
Boolean.TRUE); |
transient | Specifies
that the property value should not persisted and no code should
generated. The value must be a Boolean .
Default is false. E.g.propDesc.setValue("transient",
Boolean.TRUE); |
variableDefault | Specifies whether the default property value
depends on other property values. The value must be a Boolean .
Default is false. E.g.propDesc.setValue("variableDefault", Boolean.TRUE); |
JavaBeans support the concept of "design"-mode, when JavaBeans are used in a GUI design tool, and "run"-mode, when JavaBeans are used in an application.
You can use the method java.beans.Beans.isDesignTime()
in your JavaBean to determine whether it is running in JFormDesigner or
in your application.
JFormDesigner automatically reloads classes of custom JavaBeans when changed. So you can change the source code of used custom JavaBeans, compile them in your IDE and use them in JFormDesigner immediately without restarting.
You can also manually reload classes:
Refresh does following: