Creating event sets
You can also add event sets to your bean.
To add an event set deliverable to only one listener:
- Right-click on the
Bean Patterns
subnode of your class and choose New | Unicast Event Source from the contextual menu. The New Unicast Event Set dialog box will appear on the screen.- Use the combo box in the Type field to select or type in any listener interface (event class type) that extends
java.util.EventListener
.![]()
- Click one of the two radio buttons below the Type field to choose how you want the event set implemented. The choices are:
- Generate empty - generates an empty implementation
- Generate implementation - generates a simple implementation for one listener
- Check the Generate event firing methods box if you want to generate a method corresponding to every method in the listener interface to fire the event to all listeners.
- To specify how the event will be transferred to this method, check the option Pass event as parameter. This adds parameters to the firing events. The type of parameter (
EventObject
subclass) will be the same as the type of parameter of the corresponding method in the listener interface.If you leave the Pass event as parameter option unchecked, the firing method will have the same parameters as the constructor of the event object class (subclass of
EventObject
), and this constructor will be called in the body of the firing method. If there are multiple constructors for the event class, the generator behaves as if the Pass event as parameter option is checked.When you click OK, an
add
EventNameListener
method and aremove
EventNameListener
method, along with firing methods if you specified them, will be added to your source.For multicast event sources you can specify how to implement the adding of listeners and firing of events.
To add an event set deliverable to more than one listener:
- Right-click on the
Bean Patterns
subnode of your class and choose New | Multicast Event Source from the contextual menu. The New Multicast Event Set dialog box will appear on the screen.- In the Type field, specify any listener interface (event class type) that extends
java.util.EventListener
.- Click one of the three radio buttons below the Type field to choose how you want the event set implemented. The options are:
- Follow steps 4 and 5 in the procedure for adding unicast events.
Contents | Prev | Next | Index |