开发者

How to set a Java bean property as an expert property?

开发者 https://www.devze.com 2023-04-01 14:18 出处:网络
The Java Beans Introspection API includes in the PropertyDescriptor class the method isExper开发者_Go百科t.Bean-based GUI editors, like WindowsMaker, use this to hide or show \"exotic\" properties.

The Java Beans Introspection API includes in the PropertyDescriptor class the method isExper开发者_Go百科t. Bean-based GUI editors, like WindowsMaker, use this to hide or show "exotic" properties.

What causes a certain property of a Java bean to be considered "expert"? How does the Swing library, for example, sets certain properties as "expert properties"? How can I programmatically do the same for Java beans that I write?


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

If you have a look at the Swing source code, some Javadoc comments include a @beaninfo tag, containing such 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 @beaninfo tag.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消