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:
Alternatively, select the component in the Explorer, choose Properties from the contextual menu, and select the Events tab in the Properties window.
After you press Enter, the code for the listener and the empty body of the handler method is generated. If you do not press Enter, no code is generated.
To define an event handler using the contextual menu:
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.
![]() |
You can set the style of how the code for component events and their handlers is
generated. Choose
Tools Options. Expand
the Editing node and select Form Editor Settings. Select the Expert tab on the
property sheet and set the Listener Generation Style property. You can choose
between the Anonymous Innerclasses, One Innerclass, and Main Class styles. See
Configuring the Form Editor for a
description of these options and other Form Editor Settings.
|
| See Also | |
|---|---|
|
Managing Component Events
Removing an Event Handler Renaming an Event Handler Adding Multiple Handlers for One Event Using the Connection Wizard | |