![]() |
![]() |
VisualAge for Java includes support for JavaBeans. This section gives you a very brief introduction to JavaBeans and some details on how VisualAge for Java supports them.
JavaBeans are Java objects that behave according to the JavaBeans specification. JavaBeans (or, more simply, beans) are reusable software components that you can manipulate in a development environment like VisualAge for Java. The method signatures and class definition of a bean follow a pattern that permits environments like VisualAge for Java to determine their properties and behavior. This ability for a beans-aware environment to determine the characteristics of a bean is called introspection.
Beans have three kinds of features:
You might remember seeing these three categories when you connected the beans of the To-Do File program in the Visual Composition Editor. A bean exposes a feature when it makes that feature available to other beans.
Here are brief descriptions of the three kinds of features:
Beans can have accompanying BeanInfo classes. These classes explicitly describe the events, methods, and properties that a bean exposes. VisualAge for Java can generate BeanInfo classes for your beans. The BeanInfo class has the same name as the bean with the suffix "BeanInfo".
The BeanInfo class contains public methods that return information about the bean, including the class of the bean, the name of the class of the bean, and details about the events, methods, and properties of the bean.
In VisualAge for Java, you manipulate the characteristics of a bean in the BeanInfo page of the class browser.
The top left pane lists the features of the bean. You can specify the kinds of features the BeanInfo page shows by selecting an entry under Show in the Features menu. The following groups of features are available:
All | All features in the bean, including features that were generated by VisualAge for Java |
Normal | Features you explicitly defined for the bean |
Property | Properties |
Event | Events |
Method | Methods |
Hidden | Hidden features |
Expert | Expert features |
When you select a feature, VisualAge for Java lists information in the top right pane depending on what kind of feature is selected:
Event | Interface, listener methods, add listener method, remove listener method |
Property | Type, read method, write method |
Method | Signature |
The top right pane lists the program elements that are associated with the selected feature. If you select one of the program elements, its source is displayed in the bottom pane.
If you do not select a program element in the upper right pane, the bottom pane lists the bean information for the selected feature, including its description, display name, and whether or not it is expert or hidden.
How would you use the BeanInfo page to create and manipulate the features of a bean? The IBM Java Examples package com.ibm.ivj.examples.vc.customerinfo is an example that makes use of property features. For instance, the Address class has properties for street, city, state, and zipCode. For instructions on how to build this sample, go to the Samples portion of the online product documentation under the Visual Composition samples and select CustomerInfo.
![]() |
![]() |