Monday 26 March 2012

Delegation Event Model

•Java follows delegation event model for handling events in programs.
•In this model, a source generates events which are detected by the listeners registered with it.
•The listener processes the event and returns control to the program.
•The advantage of the delegation event model is, it separates the event handling logic from the rest of the programming logic.
•In delegation event model, a listener must be registered with the source to receive event notifications.

•Java 1.0 does not use the delegation event model. In Java 1.0, when an event is generated, it was notified to all the components even though it is not required. This is a disadvantage in Java 1.0’s event handling mechanism.
•Using delegation model is easy. It is a two step process:
1) To detect certain events, implement the required interfaces.
2) We must register/unregister the listeners with the source to receive the event notifications.

No comments:

Post a Comment