The Event Handler Dialog enables you to set source
objects to trigger events to which one or more objects with event listeners react.
You can also remove events using the Event Handler Dialog.
Whenever you define an event handler, the code for the listener and the empty
body of the handler method is generated. In addition, the default name is assigned to
the event handler.
To open the Event Handler dialog, select the component in the Inspector window and
choose the event you want the component to trigger from the Events submenu. Alternately,
you can access the dialog using the Events area of the Properties window.
Bold menu items indicate that event handlers have already been defined.
Notes:
Note that you still must add the desired
code for the new event handler in the Source Editor.
If multiple events are of the same type, you can use the same
handler for all of them. For example, you could set both focusGained and focusLost to
use the button1FocusChange handler since they are
both of the type java.awt.event.FocusEvent. You can also use the same handler
for the same event on multiple components.
When you remove an event handler, the corresponding code block is also deleted.
If more than one handler uses the same name and same block of code, deleting
a single reference to the code does not delete the code itself. Only deleting
all references will delete the corresponding code block, and a confirmation
dialog box is displayed first.
If you remove an event but do not delete the
event handler when prompted by the confirmation dialog box, an orphaned
handler remains in the guarded text block. To delete the orphaned handler,
you need to add another event handler of the same name, delete that event,
and then agree to delete the handler in the confirmation dialog box.
For more information about how to handle events in your application, including
information about the Java event model, see the Creating a GUI with JFC/Swing tutorial
at: