Event Handling

Event Handling:
In AWT components, we came to know every component generates events when interacted by the user like clicking over a button or pressing enter key, etc. Listeners handle the events. the event handling involves four types of classes.


1.Event source
2.Event classes
3.Event listners
4.Event Adapters

1.Event Source:
The event source is components, subclasses of AWT components, capable to generate events. The event source can be a button, TextField or a Frame, etc.

2.Event classes:
Almost every event source generates an event and is named by some java class. For example, the button generate Action Event and the checkbox generates ItemEvent. ALL events listed in java.awt.event package.

3.Event Listeners:
The event generated by GUI components is handled by a special group of the class known as “listeners”.Listner is an interface. Every component has its Own listeners say, AdjustmentListner handles the events of the scrollbar.

4.Event Adapters:
When a listner includes many abstract methods to override, the coding becomes heavy to the programmer. for example, to close the frame, you override seven abstract methods of WindowListener, in which in fact you are using only one method.to avoid this heavy coding, the designers come with another group of classes known as “adapters”.

Translate »