Documentation
JavaBeans
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 has:
- a "null" constructor (without parameters)
- properties defined by getter and setter methods.
JFormDesigner supports:
- Visual beans (must inherit
from
java.awt.Component). - Non-visual beans.
BeanInfo¶
JFormDesigner supports/uses
following classes/interfaces specified in the java.beans
package:
- BeanInfo
- BeanDescriptor
- EventSetDescriptor
- PropertyDescriptor
- PropertyEditor (incl. support for custom and paintable editors)
- Customizer
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.
For example implementations of BeanInfos and PropertyEditors, take a
look at the examples
in the examples
folder or examples.zip archive.
| Attribute Name | Description |
|---|---|
| isContainer (BeanDescriptor) |
Specifies
whether a component is a container or not. A container can have child
components. The value must be a Boolean.
Default is false. E.g.beanDesc.setValue("isContainer",
Boolean.TRUE); |
| containerDelegate (BeanDescriptor) |
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 a example for such a method. The value must be a String
and specifies the name of a method that takes no arguments and returns
a java.awt.Container.
E.g.beanDesc.setValue("containerDelegate",
"getContentPane"); |
| layoutManager (BeanDescriptor) |
Allows the specification of a layout manager,
which is used when adding the component to a form. If specified, then
JFormDesigner does not allow the selection of a layout manager. The
value must be a Class.
E.g.beanDesc.setValue("layoutManager", BorderLayout.class); |
| enumerationValues (PropertyDescriptor) |
Specifies
a list of valid property
values. The value must be a Object[].
For each property value, the Object[]
must contain three
items:
|
| extraPersistenceDelegates (PropertyDescriptor) |
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 (PropertyDescriptor) |
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 (PropertyDescriptor) |
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 (PropertyDescriptor) |
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 (PropertyDescriptor) |
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 (PropertyDescriptor) |
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", new
MyPropPersistenceDelegate()); |
| readOnly (PropertyDescriptor) |
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 (PropertyDescriptor) |
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 (PropertyDescriptor) |
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); |
Design time¶
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.
Reload beans¶
JFormDesigner supports reloading of JavaBeans.
Stand-alone: Just select View > Refresh from the menu or press F5.
IDE plug-ins: Click the Refresh button in the designer tool bar.
Refresh does following:
- Create a new class loader for loading JavaBeans, BeanInfos and Icons.
- Recreates the form in the active Design view.
So you can change the source code of the used JavaBeans, compile them in your IDE and use them in JFormDesigner without restarting.
Unsupported standard components
- all AWT components
