In the following sections you will learn how to implement bean properties. A bean property is a named attribute of a bean that can affect its behavior or appearance. Examples of bean properties include color, label, font, font size, and display size.
The JavaBeans™ specification defines the following types of bean properties:
• Simple – A bean property with a single value whose changes are independent of changes in any other property.
• Indexed – A bean property that supports a range of values instead of a single value.
• Bound – A bean property for which a change to the property results in a notification being sent to some other bean.
• Constrained – A bean property for which a change to the property results in validation by another bean. The other bean may reject the change if it is not appropriate.
Bean properties can also be classified as follows:
• Writable – A bean property that can be changed
o Standard
o Expert
o Preferred
• Read Only – A bean property that cannot be changed.
• Hidden – A bean property that can be changed. However, these properties are not disclosed with the BeanInfo class
BeanBuilder uses this schema to group and represent properties in the Properties window.
Simple Properties
To add simple properties to a bean, add appropriate getXXX and setXXX methods (or isXXX and setXXX methods for a boolean property).
The names of these methods follow specific rules called design patterns. These design pattern-based method names allow builder tools such as the NetBeans GUI Builder, to provide the following features:
• Discover a bean's properties
• Determine the properties' read/write attributes
• Determine the properties' types
• Locate the appropriate property editor for each property type
• Display the properties (usually in the Properties window)
• Alter the properties (at design time)
Thursday, February 28, 2008
JavaBeans Properties
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment