Defining an Event Handler

You can define event handlers using a component's property sheet or contextual menu. You can also define an event handler using the Connection wizard.

To define an event handler using the property sheet:

  1. In the Component Inspector, select the Events tab in the component's property sheet.

    Alternatively, select the component in the Explorer, choose Properties from the contextual menu, and select the Events tab in the Properties window.

  2. Click the value of the desired event in the list. Initially, the value for all events is <none>. When you click the value field, <none> is replaced with the default event name.
  3. Enter the handler name in the property sheet or the Handlers dialog box:
  4. Add your code for the new event handler in the Source Editor.

To define an event handler using the contextual menu:

  1. Right-click on a form component in the Explorer or Component Palette.
  2. Choose Events from the contextual menu and move through the submenus to choose the event. The default name is given to the event handler. Bold menu items in the Events submenus indicate event handlers that have already been defined.
  3. Add your code for the new event handler in the Source Editor.

If multiple events are of the same type (for example, focusGained and focusLost are both of the type java.awt.event.FocusEvent), you can use the same handler for all of them. For example, you could set both focusGained and focusLost to use the button1FocusChange handler. You can also use the same handler for the same event on multiple components.

See also
Managing Component Events
Removing an Event Handler
Renaming an Event Handler
Adding Multiple Handlers for One Event
Using the Connection Wizard

Legal Notices