Deleting events from a component
You can use the Java Beans view to delete an event that you added to a component.
Tip: If you do not see any events in the Java Beans view, make sure that you click the Java Beans view menu arrow and select Show Events to show events or Expert Events to show events, adapters, and listeners.To delete an event from a component, select it in the Java Beans view and use the Delete pop-up menu option or the keyboard delete key.
- Right-click the event in the Java Beans view.
- Click Delete from the pop-up menu.
- In Show Events mode this will remove from the Java source the callback method for the event. If the listener class implements an interface that requires a method body for compilation, then the method contents are cleared out rather than the method being removed entirely.
If having deleted the callback method there are no remaining method body implementations on the listener and the listener is an anonymous inner class, then the listener itself is removed together with the method that registers it with the source. In the previous example, the Window listener only has a windowOpened callback, so when windowOpened is deleted then the listener and the addWindowListener(...) statement that adds it to the source will be removed.
- In Expert Events mode, when a callback method is deleted it is removed from the listener, or replaced with an empty method body if the listener implements the interface and must have a method to successfully compile. Unlike "Show Events" however, no cascaded delete of the listener is done, so even if the listener has no remaining callback method bodies left is it not automatically removed.
Delete in Expert Events mode can be thought of as deleting the selected tree item from its parent.
The listener itself can also be selected and deleted. This will remove the listener from the Java Bean. If the listener is an anonymous inner class it will be removed from the source. However, for a name listener class it will still remain after it has been removed from Java beans that use it.
Parent topic
Handling events with the visual editor
Related concepts
The Java Beans view
Related tasks
Adding events to a component
Viewing events for a component
Viewing the source for an event