Event类代表事件。Java为我们提供了各种Event类,但我们将讨论更常用的类。

EventObject类

它是从其派生所有事件状态对象的根类。所有事件都是通过对对象source的引用构造的,该对象在逻辑上被视为最初发生有关事件的对象。此类在java.util包中定义。

类声明

Following is the declaration for java.util.EventObject class:

  1. public class EventObject
  2. extends Object
  3. implements Serializable

Field

以下是java.util.EventObject类的声明:

  • protected Object source — The object on which the Event initially occurred.

类的构造函数

S.N.Constructor & Description
1

EventObject(Object source)

Constructs a prototypical Event.

类方法

S.N.Method & Description
1

Object getSource()

The object on which the Event initially occurred.

2

String toString()

Returns a String representation of this EventObject.

方法继承

此类从以下类继承方法:

  • java.lang.Object

AWT Event Classes:

以下是常用事件类的列表。

Sr. No.Control & Description
1

AWTEvent

It is the root event class for all AWT events. This class and its subclasses supercede the original java.awt.Event class.

2

ActionEvent

The ActionEvent is generated when button is clicked or the item of a list is double clicked.

3

InputEvent

The InputEvent class is root event class for all component-level input events.

4

KeyEvent

On entering the character the Key event is generated.

5

MouseEvent

This event indicates a mouse action occurred in a component.

6

TextEvent

The object of this class represents the text events.

7

WindowEvent

The object of this class represents the change in state of a window.

8

AdjustmentEvent

The object of this class represents the adjustment event emitted by Adjustable objects.

9

ComponentEvent

The object of this class represents the change in state of a window.

10

ContainerEvent

The object of this class represents the change in state of a window.

11

MouseMotionEvent

The object of this class represents the change in state of a window.

12

PaintEvent

The object of this class represents the change in state of a window.