Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

SWING event listener


May 15, 2021 SWING


Table of contents


SWING event listener

The event listener represents the interface responsible for handling the event. J ava provides a variety of event listener classes, but we'll discuss those that are used more frequently. E ach method of an event listener has an argument as an object that is a sub-class of the EventObject class. For example, the mouse event listener's method accepts an instance of MouseEvent, where MouseEvent is derived from EventObject.

EventListner interface

It is a tag interface that must be extended by each listener interface. This class is defined in the java.util package.

Class declaration

Here's a statement from the java.util.EventListener interface:

public interface EventListener

SWING Event Listener Interface:

Below is a list of common event listeners.

Sr. No. Control and description
1 ActionListener
This interface is used to receive action events.
2 ComponentListener
This interface is used to receive component events.
3 ItemListener
This interface is used to receive project events.
4 KeyListener
This interface is used to receive keystroke events.
5 MouseListener
This interface is used to receive mouse events.
6 WindowListener
This interface is used to receive window events.
7 AdjustmentListener
This interface is used to receive adjustment events.
8 ContainerListener
This interface is used to receive container events.
9 MouseMotionListener
This interface is used to receive mouse movement events.
10 FocusListener
This interface is used to receive focus events.