Defining Bean Interfaces for Visual Composition

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:

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:


Related concepts
Bean Interfaces and BeanInfo
How Classes and Beans Are Related
Generated Code

Related procedures
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

Related references
BeanInfo Page
Features--BeanInfo Page

Creating and Modifying a BeanInfo Class

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:

You can explicitly create a BeanInfo class in the BeanInfo page as follows:

  1. From the Features menu, select New BeanInfo Class to open the SmartGuide - BeanInfo Class window.

  2. 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.

  3. 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.


Related concepts
Bean Interfaces and BeanInfo
Generated BeanInfo Descriptor Code (an advanced topic)
Object Serialization in VisualAge

Related procedures
Defining Bean Interfaces for Visual Composition

Related references
BeanInfo Class SmartGuide
Bean Icon Information SmartGuide
Information Pane--BeanInfo Page

Adding Property Features

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:

  1. From the tool bar, select (New Property icon) 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.

  2. In the SmartGuide - New Property Feature window, do the following:

    1. Specify the property name in the Property name field.

    2. Specify the property type in the Property type field.

    3. 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.

    4. 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.

    5. If you want the property to send value changes on connections, make sure that the bound check box is selected.

    6. 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.

    7. If you want other beans to be able to veto value changes for the property, select the constrained check box.

    8. Select Next to open the SmartGuide - Bean Information window.

  3. In the SmartGuide - Bean Information window, do the following:

    1. 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.

    2. 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.

    3. 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.

    4. If you do not want the property to be exposed to the bean consumer, select the hidden check box.

    5. If you want to provide customized initialization of the property, specify a property editor class.

    6. 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.


Related concepts
Feature Naming Guidelines
Generated Code

Related procedures
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Specifying Expert Features
Specifying Hidden Features

Related references
New Property Feature SmartGuide
Bean Information SmartGuide
Features Pane--BeanInfo Page

Adding Method Features

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:

  1. From the tool bar, select (New method icon) 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.

  2. In the SmartGuide - New Method Feature window, do the following:

    1. Specify the method name in the Method name field.

    2. Specify the method return type in the Return type field.

    3. If your method feature requires parameter input, specify the number of parameters in the Parameter count field.

    4. Select Next to open the either the SmartGuide - Parameter window or the SmartGuide - Bean Information window.

  3. In the SmartGuide - Parameter window for each parameter, do the following:

    1. Specify the parameter name in the Parameter name field.

    2. Specify the parameter type in the Parameter type field.

    3. 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.

    4. 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.

    5. Select Next to open the SmartGuide - Bean Information window.

  4. In the SmartGuide - Bean Information window, do the following:

    1. 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.

    2. 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.

    3. 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.

    4. If you do not want the method to be exposed to the bean consumer, select the hidden check box.

    5. 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.


Related concepts
Feature Naming Guidelines
Generated Code

Related procedures
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Specifying Expert Features
Specifying Hidden Features

Related references
New Method Feature SmartGuide
Parameter SmartGuide
Bean Information SmartGuide
Features Pane--BeanInfo Page

Adding Event Features

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:

  1. From the tool bar, select (New event icon) 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.

  2. In the SmartGuide - New Event Set Feature window, do the following:

    1. Specify the event name in the Event name field.

    2. Select an event listener in the Event listener list.

    3. Select Next to open the SmartGuide - Bean Information window.

  3. In the SmartGuide - Bean Information window, do the following:

    1. 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.

    2. 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.

    3. 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.

    4. If you do not want the event to be exposed to the bean consumer, select the hidden check box.

    5. 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:

  1. Select New Listener Interface from the Features menu to open the SmartGuide - New Event Listener window.

  2. In the SmartGuide - New Event Listener window, do the following:

    1. Specify the event name in the Event name field.

    2. 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.

    3. 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.

    4. 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.

    5. Select Next to open the SmartGuide - Event Listener Methods window.

  3. In the SmartGuide - Event Listener Methods window, do the following:

    1. 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.

    2. Select Next to open the SmartGuide - Bean Information window.

  4. In the SmartGuide - Bean Information window, do the following:

    1. 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.

    2. 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.

    3. 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.

    4. If you do not want the event to be exposed to the bean consumer, select the hidden check box.

    5. 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.


Related concepts
Feature Naming Guidelines
Generated Code

Related procedures
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class
Specifying Expert Features
Specifying Hidden Features

Related references
New Event Set Feature SmartGuide
New Event Listener SmartGuide
Event Listener Methods SmartGuide
Bean Information SmartGuide
Features Pane--BeanInfo Page

Promoting Features of Embedded Beans

Promote features in the Visual Composition Editor as follows:

  1. From the pop-up menu of the embedded bean, select Promote bean feature to open the Promote Features window.

  2. For each feature that you want to promote, do the following:
    1. Select Method, Property, or Event to filter promotable features in the features list box.
    2. In the features list box, select the feature you are promoting.
    3. Select the >> button. The feature is moved to the Promoted features list.
    4. 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.

  3. Select OK to close the Promote Features window.

  4. Save the composite bean to incorporate the features you just promoted. If you run the test tool, the bean is automatically saved.


Related concepts
Default Promoted Feature Names
Feature Naming Guidelines
Generated Code

Related procedures
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class

Related references
Promote Features Window

Specifying Expert Features

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:


Related concepts
Generated Code

Related procedures
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class

Related references
Bean Information SmartGuide
Information Pane--BeanInfo Page

Specifying Hidden Features

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:


Related concepts
Generated Code

Related procedures
Defining Bean Interfaces for Visual Composition
Creating and Modifying a BeanInfo Class

Related references
Bean Information SmartGuide
Information Pane--BeanInfo Page