What steps are required to handle event by using Delegation Model? Explain event objects.
In Delegation model Listener needs to be registered with the source object so that the listener can receive the event notification. This is an efficient way of handling the event because the event notifications are sent only to those listeners that want to receive them.
Following steps are required to perform event handling.
1. Implement the Listener interface and overrides its methods
2. Register the component with the Listener
3. Put proper code in required overridden method
Events Object
- In the delegation model, an event is an object that describes a state change in a source. It can be generated as a consequence of a person interacting with the elements in a graphical user interface. Some of the activities that cause events to be generated are pressing a button, entering a character via the keyboard, selecting an item in a list, clicking the mouse etc. Events may also occur that are not directly caused by interactions with a user interface For example, an event may be generated when a timer expires, a counter exceeds a value, software or hardware failure occurs, or an operation is completed. Some of the commonly used AWT events are: ActionEvents, KeyEvents, MouseEvents etc.
Comments
Post a Comment