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