Event Handling
Advertisements
Event Handling in AWT
In general you can not perform any operation on dummy GUI screen even any button click or select any item. To perform some operation on these dummy GUI screen you need some predefined classes and interfaces. All these type of classes and interfaces are available in java.awt.event package.
Changing the state of an object is known as an event.
The process of handling the request in GUI screen is known as event handling (event represent an action). It will be changes component to component.
Note: In event handling mechanism event represent an action class and Listener represent an interface. Listener interface always contains abstract methods so here you need to write your own logic.
Event classes and Listener interfaces
Event Classes | Listener Interfaces |
---|---|
ActionEvent | ActionListener |
MouseEvent | MouseListener and MouseMotionListener |
MouseWheelEvent | MouseWheelListener |
KeyEvent | KeyListener |
ItemEvent | ItemListener |
TextEvent | TextListener |
AdjustmentEvent | AdjustmentListener |
WindowEvent | WindowListener |
ComponentEvent | ComponentListener |
ContainerEvent | ContainerListener |
FocusEvent | FocusListener |
Steps to perform Event Handling
Following steps are required to perform event handling:
- Implement the Listener interface and overrides its methods
- Register the component with the Listener
Google Advertisment