# Event Handler Dialog

Use 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.

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.

Related Topics

Developing Applications with NetBeans IDE,

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.