Event Handling


Prev Tutorial Next Tutorial

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 ClassesListener Interfaces
ActionEventActionListener
MouseEventMouseListener and MouseMotionListener
MouseWheelEventMouseWheelListener
KeyEventKeyListener
ItemEventItemListener
TextEventTextListener
AdjustmentEventAdjustmentListener
WindowEventWindowListener
ComponentEventComponentListener
ContainerEventContainerListener
FocusEventFocusListener

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

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements