How to set Java bean property as an expert property?

The Java Beans Introspection API API includes a PropertyDescriptormethod in the class isExpert. Bean based image editors, such as WindowsMaker, use this to hide or show "exotic" properties.

What makes a particular Java bean property be considered an "expert"? How does the Swing library, for example, set certain properties as "expert properties"? How can I programmatically do the same for the Java Beans that I am writing?

+5
source share
2 answers

You can create a BeanInfo class for your bean. This allows you to customize the property descriptor. A section on this in the JavaBean tutorial .

+1
source

This is apparently done in the JDK using a non-standard compiler extension.

If you look at the Swing source code, some Javadoc comments include a tag @beaninfocontaining this information:

/**
 * ... Some comment ...
 * @beaninfo
 *        bound: true
 *       expert: true
 */
public void setSomething(SomeType value) {
    // ...
}

Here is an example in the JTable class source code .

I also found this article talking about the tag @beaninfo.

+2
source

All Articles