Event Handling in Applet

Event Handling is a mechanism that is used to handle events generated by applets. An event could be the occurrence of any activity such as a mouse click or keypress. In Java, events are regarded as method calls with a certain task performed against the occurrence of each event.
Some of the Event handling methods in Applet is given as follows :

Key Events Description
ActionEventIt is triggered whenever a user interface element is activated.
Example: Selected of a menu item
ItemEventIt is triggered at the selection or deselection of a list element.
Example: Checkbox
TextEventIt is triggered when a text field is modified
WindowEventIt is triggered whenever a window-related operation is performed.
Example: Closing or activating window
KeyEventIt is triggered whenever a key is pressed on the keyboard.

Each event is associated with an event source and an event handler.

Event source: It refers to the object that is responsible for generating an event.

public void add<Type>Listener(<Type>Listener EveList)  

Where Type is the name of the event & EveList is the corresponding listener object reference.

EventListener: EventListener is the object that is referred by event source at the time of occurrence of an event. These methods are implemented from the corresponding listener interface contained in the java.awt.event package.

Recommended Posts:

Advanced Java
    1. Java Applet
    2. Applet Life Cycle in Java
    3. Difference Between Applet and Application
    4. Creating an Executable Applet in Java
    5. Displaying Numerical values in Applet
    6. An Applet Program to Add Two Numbers
    7. Event Handling in Applet
    8. AWT Event Classes
    9. AWT Graphics Class
    10. Draw a line and rectangle in Java Applet
    11. Draw Circles and Ellipses in Java Applet
    12. Draw a Polygon in Java Applet
    13. AWT Hierarchy | AWT Package
    14. Swing in Core Java