The bean interface defines the property, event, and method features of your
bean. These features can be used in visual composition when your bean
is added to another bean. A BeanInfo class describes the bean and
features that you add to the bean. Other features are inherited from
the superclass of your bean unless you choose not to inherit features.
See the related conceptual topic about bean interfaces for more
information.
Add features to the bean interface in the BeanInfo page. You can use
either the tool bar or Features menu to add a new feature.
When you add a feature, VisualAge generates the following:
- Public methods for the feature in the bean class
- Bean information code that describes the feature in the BeanInfo class for
the bean
If you create public methods for the bean in the Methods page, you can add
them as features in the BeanInfo page. Select Add Available
Features from the Features menu to open the Add Available
Features window and add methods as features.
Promote features of embedded beans in the Visual Composition Editor.
You can promote features from the pop-up menu of an embedded bean. When
you promote a feature, VisualAge generates the following:
- Public methods in the bean class that call methods of the embedded bean
- Bean information code that describes the feature in the BeanInfo class for
the bean
Bean Interfaces and BeanInfo
How Classes and Beans Are Related
Generated Code
Creating and Modifying a BeanInfo Class
Adding Property Features
Adding Method Features
Adding Event Features
Promoting Features of Embedded Beans
Specifying Expert Features
Specifying Hidden Features
BeanInfo Page
Features--BeanInfo Page
When you create a new bean, it does not initially have a BeanInfo
class. VisualAge automatically creates a BeanInfo class for a bean if
one does not exist and you do any of the following:
- Modify a BeanInfo property in the Information pane of the
BeanInfo page. VisualAge generates bean information code that describes
the bean.
- Add a new feature in the BeanInfo page. VisualAge generates bean
information code that describes the bean and the new feature.
- Promote a feature of an embedded bean in the Visual Composition
Editor. VisualAge generates bean information code that describes the
bean and the promoted feature.
You can explicitly create a BeanInfo class in the BeanInfo page as
follows:
- From the Features menu, select New BeanInfo Class to
open the SmartGuide - BeanInfo Class window.
- In the SmartGuide - BeanInfo Class window, you can specify a display
name and short description to use for the bean. If you want to provide
customized initialization of bean properties, specify a customizer class for
the bean. Select Next to open the SmartGuide - Bean
Icon Information window.
- In the SmartGuide - Bean Icon Information window, you can specify
files containing icons for the bean. Select Finish to create
the BeanInfo class.
You can also create or replace a BeanInfo class in the BeanInfo page as
follows. From the Features menu, select Generate
BeanInfo class. VisualAge generates bean information code that
describes the bean and all features that you have added or promoted to the
bean interface.
To modify the information in a BeanInfo class, edit bean information
properties in the Information pane of the BeanInfo page. If
no feature is selected in the Features pane, you can edit bean
information for the bean. If a feature is selected, you can edit bean
information for the feature.
If you want a bean to be serialized, set the Hidden-state
property of the bean to true in the Information
pane.
Bean Interfaces and BeanInfo
Generated BeanInfo Descriptor Code (an advanced topic)
Object Serialization in VisualAge
Defining Bean Interfaces for Visual Composition
BeanInfo Class SmartGuide
Bean Icon Information SmartGuide
Information Pane--BeanInfo Page
Define property features to represent bean data or attributes that you want
other beans to have access to.
Add a new property feature in the BeanInfo page as follows:
- From the tool bar, select
New Property Feature. If you prefer, you can select
New Property Feature from the Features menu.
Either selection opens the SmartGuide - New Property Feature
window.
- In the SmartGuide - New Property Feature window, do the
following:
- Specify the property name in the Property name field.
- Specify the property type in the Property type field.
- If you want the property value to be retrievable, make sure that the
Readable check box is selected. If this option is selected,
a get method is generated for the property.
- If you want the property value to be modifiable, make sure that the
Writeable check box is selected. If this option is selected,
a set method is generated for the property.
- If you want the property to send value changes on connections, make sure
that the bound check box is selected.
- If the property consists of an array of elements, select the
Indexed check box. After you finish adding the property
feature, select Add Available Features from the Features
menu to add the get and set array element methods as features so you can make
connections to them.
- If you want other beans to be able to veto value changes for the property,
select the constrained check box.
- Select Next to open the SmartGuide - Bean Information
window.
- In the SmartGuide - Bean Information window, do the following:
- If you want a name other than the actual feature name to be displayed for
the property in the Visual Composition Editor, specify the name in the
Display name field. This name appears when the property is
listed in connection menus, the bean property sheet, and other windows.
- If you want a description other than the feature name to be displayed for
the property in the Visual Composition Editor, specify the description in the
Short description field. This description appears in certain
windows, such as connection windows and the Promote Features window, when the
property is selected.
- If you do not want the property to appear in development windows unless
the user chooses to display expert features, select the expert
check box.
- If you do not want the property to be exposed to the bean consumer, select
the hidden check box.
- If you want to provide customized initialization of the property, specify
a property editor class.
- Select Finish to add the property. VisualAge generates
the following:
- Public methods for the feature in the bean class
- Bean information code that describes the feature in the BeanInfo class for
the bean
You can modify BeanInfo for the property in the Information pane
of the BeanInfo page. If you want the property to appear as a preferred
feature in the connection menu of the bean, set the feature's
Preferred property to true. If you do not want
the property to appear in the property sheet of the bean, set the
feature's Design time property property to
false.
Feature Naming Guidelines
Generated Code
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Specifying Expert Features
Specifying Hidden Features
New Property Feature SmartGuide
Bean Information SmartGuide
Features Pane--BeanInfo Page
Define method features to represent bean behaviors or functions that you
want other beans to have access to.
Add a new method feature in the BeanInfo page as follows:
- From the tool bar, select
New Method Feature. If you prefer, you can select New
Method Feature from the Features menu. Either
selection opens the SmartGuide - New Method Feature window.
- In the SmartGuide - New Method Feature window, do the
following:
- Specify the method name in the Method name field.
- Specify the method return type in the Return type field.
- If your method feature requires parameter input, specify the number of
parameters in the Parameter count field.
- Select Next to open the either the SmartGuide - Parameter
window or the SmartGuide - Bean Information window.
- In the SmartGuide - Parameter window for each parameter, do the
following:
- Specify the parameter name in the Parameter name field.
- Specify the parameter type in the Parameter type field.
- If you want a name other than the actual parameter name to be displayed
for the parameter in the Visual Composition Editor, specify the name in the
Display name field. This name appears when the parameter is
listed in visual composition windows.
- If you want a description other than the feature name to be displayed for
the parameter in the Visual Composition Editor, specify the description in the
Short description field. This description appears when the
parameter is selected in visual composition windows.
- Select Next to open the SmartGuide - Bean Information
window.
- In the SmartGuide - Bean Information window, do the following:
- If you want a name other than the actual feature name to be displayed for
the method in the Visual Composition Editor, specify the name in the
Display name field. This name appears when the method is
listed in connection menus, the Promote Features window, and other
windows.
- If you want a description other than the feature name to be displayed for
the method in the Visual Composition Editor, specify the description in the
Short description field. This description appears in certain
windows, such as connection windows and the Promote Features window, when the
method is selected.
- If you do not want the method to appear in development windows unless the
user chooses to display expert features, select the expert check
box.
- If you do not want the method to be exposed to the bean consumer, select
the hidden check box.
- Select Finish to add the method. VisualAge generates the
following:
- A public method for the feature in the bean class
- Bean information code that describes the feature in the BeanInfo class for
the bean
You can modify BeanInfo for the method in the Information pane
of the BeanInfo page. If you want the method to appear as a preferred
feature in the connection menu of the bean, set the feature's
Preferred property to true.
Feature Naming Guidelines
Generated Code
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Specifying Expert Features
Specifying Hidden Features
New Method Feature SmartGuide
Parameter SmartGuide
Bean Information SmartGuide
Features Pane--BeanInfo Page
Define event features to represent the occurrence of any events in your
bean that you want other beans to be aware of.
You can add an event feature in the BeanInfo page based on either an
existing event set or a new event set that you define. An event
set consists of an event listener interface with associated event object
and multicaster classes. The multicaster enables multiple listeners for
an event.
Add an event feature based on an existing event set in the BeanInfo page as
follows:
- From the tool bar, select
New Event Set Feature. If you prefer, you can select
New Event Set Feature from the Features menu.
Either selection opens the SmartGuide - New Event Set Feature
window.
- In the SmartGuide - New Event Set Feature window, do the
following:
- Specify the event name in the Event name field.
- Select an event listener in the Event listener list.
- Select Next to open the SmartGuide - Bean Information
window.
- In the SmartGuide - Bean Information window, do the following:
- If you want a name other than the actual feature name to be displayed for
the event in the Visual Composition Editor, specify the name in the
Display name field. This name appears when the event is
listed in connection menus, the Promote Features window, and other
windows.
- If you want a description other than the feature name to be displayed for
the event in the Visual Composition Editor, specify the description in the
Short description field. This description appears in certain
windows, such as connection windows and the Promote Features window, when the
event is selected.
- If you do not want the event to appear in development windows unless the
user chooses to display expert features, select the expert check
box.
- If you do not want the event to be exposed to the bean consumer, select
the hidden check box.
- Select Finish to add the method. VisualAge generates the
following:
- A public method for the feature in the bean class
- Bean information code that describes the feature in the BeanInfo class for
the bean
Add an event feature based on a new event set in the BeanInfo page as
follows:
- Select New Listener Interface from the Features menu
to open the SmartGuide - New Event Listener window.
- In the SmartGuide - New Event Listener window, do the
following:
- Specify the event name in the Event name field.
- Specify the event listener name in the Event listener
field. A default name is produced based on the name you specify in the
Event name field.
- Specify the event object name in the Event object field.
A default name is produced based on the name you specify in the Event
name field.
- Specify the event multicaster name in the Event Multicaster
field. A default name is produced based on the name you specify in the
Event name field.
- Select Next to open the SmartGuide - Event Listener
Methods window.
- In the SmartGuide - Event Listener Methods window, do the
following:
- For each method that you want to add to the listener, specify the method
in the Method name field. Then, select the Add
button. These listener methods respond to the event. You must
add code that responds to the event in each method.
- Select Next to open the SmartGuide - Bean Information
window.
- In the SmartGuide - Bean Information window, do the following:
- If you want a name other than the actual feature name to be displayed for
the event in the Visual Composition Editor, specify the name in the
Display name field. This name appears when the event is
listed in connection menus, the Promote Features window, and other
windows.
- If you want a description other than the feature name to be displayed for
the event in the Visual Composition Editor, specify the description in the
Short description field. This description appears in certain
windows, such as connection windows and the Promote Features window, when the
event is selected.
- If you do not want the event to appear in development windows unless the
user chooses to display expert features, select the expert check
box.
- If you do not want the event to be exposed to the bean consumer, select
the hidden check box.
- Select Finish to add the method. VisualAge generates the
following:
- A public method for the feature in the bean class
- Bean information code that describes the feature in the BeanInfo class for
the bean
You can modify BeanInfo for the event in the Information pane of
the BeanInfo page. If you want the event to appear as a preferred
feature in the connection menu of the bean, set the feature's
Preferred property to true.
Feature Naming Guidelines
Generated Code
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Specifying Expert Features
Specifying Hidden Features
New Event Set Feature SmartGuide
New Event Listener SmartGuide
Event Listener Methods SmartGuide
Bean Information SmartGuide
Features Pane--BeanInfo Page
Promote features in the Visual Composition Editor as follows:
- From the pop-up menu of the embedded bean, select Promote bean
feature to open the Promote Features window.
- For each feature that you want to promote, do the following:
- Select Method, Property, or Event to
filter promotable features in the features list box.
- In the features list box, select the feature you are promoting.
- Select the >> button. The feature is moved to the
Promoted features list.
- If you do not want to use the default name, double-click the feature name
in the Promote feature name field. Then, edit the name to
change it.
- Select OK to close the Promote Features window.
- Save the composite bean to incorporate the features you just
promoted. If you run the test tool, the bean is automatically
saved.
Default Promoted Feature Names
Feature Naming Guidelines
Generated Code
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Promote Features Window
You can designate expert features that you do not normally want
listed in development windows. These are features that are complex or
easily misused.
To designate a feature as expert, do either of the following:
- When adding the feature, select the expert check box in the
SmartGuide - Bean Information window.
- Edit the bean information in the Information pane of the
BeanInfo page. Select the Expert property, then select
true in the value column.
Generated Code
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Bean Information SmartGuide
Information Pane--BeanInfo Page
You can designate hidden features that you do not want to be
available for connections and property settings. These are features
that you use within the bean for implementation that you do not want
exposed.
To designate a feature as hidden, do either of the following:
- When adding the feature, select the hidden check box in the
SmartGuide - Bean Information window.
- Edit the bean information in the Information pane of the
BeanInfo page. Select the Hidden property, then select
true in the value column.
Generated Code
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Bean Information SmartGuide
Information Pane--BeanInfo Page
