Explain Java’s delegation event model The event model is based on the Event Source and Event Listeners. Event Listener is an object that receives the messages / events. The Event Source is any object which creates the message / event. The Event Delegation model is based on – The Event Classes, The Event Listeners, Event Objects.
There are three participants in event delegation model in Java;
- Event Source – the class which broadcasts the events - Event Listeners – the classes which receive notifications of events - Event Object – the class object which describes the event.
An event occurs (like mouse click, key press, etc) which is followed by the event is broadcasted by the event source by invoking an agreed method on all event listeners. The event object is passed as argument to the agreed-upon method. Later the event listeners respond as they fit, like submit a form, displaying a message / alert etc.
|