📜  SWING-事件类

📅  最后修改于: 2020-11-10 04:47:42             🧑  作者: Mango


事件类表示事件。 Java提供了各种Event类,但是,仅讨论那些更常用的类。

EventObject类别

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

类声明

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

public class EventObject
   extends Object
      implements Serializable

领域

以下是java.util.EventObject类的字段-

protected Object source-事件最初发生的对象。

类构造器

Sr.No. Constructor & Description
1

EventObject(Object source)

Constructs a prototypical Event.

类方法

Sr.No. 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

摇摆事件类

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

Sr.No. Class & Description
1 AWTEvent

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

2 ActionEvent

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

3 InputEvent

The InputEvent class is the 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 WindowEvent

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

7 AdjustmentEvent

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

8 ComponentEvent

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

9 ContainerEvent

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

10 MouseMotionEvent

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

11 PaintEvent

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