Change in the state of an object is known as event i. Events are generated as result of user interaction with the graphical user interface components. For example, clicking on a button, moving the mouse, entering a character through keyboard,selecting an item from list, event delegation model in java pdf the page are the activities that causes an event to happen.
For example, clicking on a button, moving the mouse, entering a character through keyboard,selecting an item from list, scrolling the page etc. Operating system interrupts, hardware or software failure, timer expires, an operation completion are the example of background events. Event Handling is the mechanism that controls the event and decides what should happen if an event occurs. Java Uses the Delegation Event Model to handle the events.
This model defines the standard mechanism to generate and handle the events. Let’s have a brief introduction to this model. Source – The source is an object on which event occurs. Source is responsible for providing information of the occurred event to it’s handler.
Java provide as with classes for source object. Listener – It is also known as event handler. Listener is responsible for generating response to an event. From java implementation point of view the listener is also an object.
Listener waits until it receives an event. Once the event is received , the listener process the event an then returns. The benefit of this approach is that the user interface logic is completely separated from the logic that generates the event.