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:
<none>
. When you click the value field,
<none>
is replaced with the default event name.
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.
See also | |
---|---|
Managing Component Events
Removing an Event Handler Renaming an Event Handler Adding Multiple Handlers for One Event Using the Connection Wizard |