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

SWING event class


May 15, 2021 SWING


Table of contents


SWING event class

The event class represents the event. Java provides a variety of event classes, but we'll discuss those that are used more frequently.

EventObject class

It is the root class that derives all event state objects. A ll events are constructed with a reference to the object, the source , which is logically considered to be the object of the event in which the problem originally occurred. This class is defined in the java.util package.

Class declaration

Here's the declaration of the java.util.EventObject class:

public class EventObject
   extends Object
      implements Serializable

Field

Here are the fields for the java.util.EventObject class:

  • ObjectEd Source - The object from which the event originally occurred.

Class constructor

S.N. Constructor and description
1 EventObject(Object source)
Construct a typical event.

Class method

S.N. Methods and descriptions
1 Object getSource()
The object from which the event originally occurred.
2 String toString()
Returns this string represent of EventObject.

Method inheritance

This class inherits the method from the following class:

  • java.lang.Object

SWING event class:

The following are commonly used event classes.

Sr. No. Control and description
1 AWTEvent
It is the root event class for all SWING events. This class and its sub-classes replace the original java.awt.Event class.
2 ActionEvent
When you click a button or double-click an item in a list, ActionEvent is generated.
3 InputEvent
The InputEvent class is the root event class for all component layer input events.
4 KeyEvent
When a character is pressed, key events are generated.
5 MouseEvent
This event indicates that a mouse action occurs in a component.
6 WindowEvent
Objects of this class represent changes in the state of a window.
7 AdjustmentEvent
The objects of this class represent adjustment events emitted by adjustable objects.
8 ComponentEvent
Objects of this class represent changes in the state of a window.
9 ContainerEvent
Objects of this class represent changes in the state of a window.
10 MouseMotionEvent
Objects of this class represent changes in the state of a window.
11 PaintEvent
Objects of this class represent changes in the state of a window.