Adding and Deleting Events

Using the WFC Component Builder, you can easily add and delete event definitions in your WFC-based components. Because an event uses a delegate to invoke its event handler, your component provides public addOn<EventName> and removeOn<EventName> methods to add and remove the delegate. Your component also defines a protected on<EventName> method that triggers the event. For more information about WFC events, see WFC Fundamental Programming Concepts.

When you add an event with the WFC Component Builder, the associated methods and the member variable for the delegate are automatically added to your class. The builder also adds the event information to your component's ClassInfo class. ClassInfo allows information about your component to be publicized in a property browser, such as the Properties window.

Note   If your component does not contain a ClassInfo definition, the WFC Component Builder inserts one into your class.

When you delete an event with the WFC Component Builder, the associated ClassInfo entry, delegate, and methods are automatically deleted from your class.

To open the WFC Component Builder

  1. Open your component's source file in the Text editor.

  2. In Class Outline, right-click the name of your class, and then click WFC Component Builder on the shortcut menu.

To add an event

  1. In the Events pane of the WFC Component Builder, click Add.

  2. In the Event Name box, type the name of the event.

  3. In the Type drop-down list, select an event type. (You can enter a type that is not in the list if classes named <EventType> and <EventType>Handler are on the classpath or available in the Java Package Manager.)

  4. In the Category drop-down list, you can optionally select a category. Categories allow you to group related events in the Properties window.

  5. Type any description text in the Description box. Event descriptions are displayed in the Properties window.

  6. Click Add.

  7. To add another event, repeat the previous steps. (When adding or deleting multiple items in the WFC Component Builder, periodically click Apply to ensure your changes are saved.)

  8. Click OK to close the WFC Component Builder.

To delete an event

  1. In the Events pane of the WFC Component Builder, select the event you want to delete.

    Note   Deleting an event deletes all associated methods, delegates, and ClassInfo information. Any code that you have added to the methods will be lost. However, you can undo multiple levels of deletion from the Text editor, after the WFC Component Builder is closed. On the Edit menu, click Undo for each deleted item that you want to restore.

  2. Click Delete.

  3. To delete another event, repeat the previous steps. (When adding or deleting multiple items in the WFC Component Builder, periodically click Apply to ensure your changes are saved.)

  4. Click OK to close the WFC Component Builder.