@Target(value=TYPE) @Retention(value=RUNTIME) public @interface BeanInfo
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 PropertyDescriptor
s.
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 { ... }
Modifier and Type | Optional Element and Description |
---|---|
BeanInfo.Attribute[] |
attributes
Specifies additional named attributes for the
BeanDescriptor . |
BeanInfo.Category[] |
categories
Specifies categories for grouping properties in the JFormDesigner Properties view.
|
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.
|
Class<? extends Customizer> |
customizer
Specifies the bean's customizer.
|
String |
description
Description of the JavaBean.
|
String |
icon
Resource name of a 16x16 color icon of the JavaBean.
|
boolean |
isContainer
Specifies whether a component is a container or not.
|
String[] |
persistenceConstructorProperties
Specifies the property names for a
DefaultPersistenceDelegate(String[])
used to persist an instance of the annotated class. |
Class<? extends PersistenceDelegate> |
persistenceDelegate
Specifies the persistence delegate used to persist an instance of the annotated class.
|
PropertyDesc[] |
properties
Specifies property descriptors.
|
public abstract String description
Used in the JFormDesigner Palette to display descriptions of beans in tooltips.
public abstract String icon
JFormDesigner uses beanClass.getResource(icon)
to locate the icon file.
public abstract Class<? extends Customizer> customizer
Customizer
and inherit from
Component
so it can be instantiated inside an dialog.public abstract boolean isContainer
public abstract String containerDelegate
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
.public abstract PropertyDesc[] properties
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.
public abstract BeanInfo.Category[] categories
BeanInfo.Category
for details.public abstract String[] persistenceConstructorProperties
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; } }
public abstract Class<? extends PersistenceDelegate> persistenceDelegate
persistenceConstructorProperties()
is specified, then this attribute is ignored.
Used by JFormDesigner to encode/decode the property value to XML.
public abstract BeanInfo.Attribute[] attributes
BeanDescriptor
.
Invokes FeatureDescriptor.setValue(String, Object)
.
See BeanInfo.Attribute
for details.Copyright (C) 2004-2019 FormDev Software GmbH. All rights reserved.