Swing 简明教程
SWING - Event Classes
事件类表示事件。Java 提供各种事件类,但仅讨论最常用的事件类。
Event classes represent the event. Java provides various Event classes, however, only those which are more frequently used will be discussed.
EventObject Class
它是所有事件状态对象派生的根类。所有事件均使用对对象的引用 source 构造,该对象在逻辑上被认为是事件最初发生的上的对象。此类在 java.util 包中定义。
It is the root class from which all event state objects shall be derived. All Events are constructed with a reference to the object, the source, that is logically deemed to be the object upon which the Event in question initially occurred upon. This class is defined in java.util package.
Class Declaration
以下是对 java.util.EventObject 类的声明 −
Following is the declaration for java.util.EventObject class −
public class EventObject
extends Object
implements Serializable
Field
以下是对 java.util.EventObject 类的字段 −
Following are the fields for java.util.EventObject class −
protected Object source − 事件最初发生的对象。
protected Object source − The object on which the Event initially occurred.
Class Constructors
Sr.No. |
Constructor & Description |
1 |
EventObject(Object source) Constructs a prototypical Event. |
Class Methods
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. |
Methods Inherited
此类从以下类继承方法 −
This class inherits methods from the following class −
-
java.lang.Object
SWING Event Classes
以下是常用事件类的列表。
Following is the list of commonly used Event classes.
Sr.No. |
Class & Description |
1 |
AWTEventIt is the root event class for all SWING events. This class and its subclasses supercede the original java.awt.Event class. |
2 |
ActionEventThe ActionEvent is generated when the button is clicked or the item of a list is double-clicked. |
3 |
InputEventThe InputEvent class is the root event class for all component-level input events. |
4 |
KeyEventOn entering the character the Key event is generated. |
5 |
MouseEventThis event indicates a mouse action occurred in a component. |
6 |
WindowEventThe object of this class represents the change in the state of a window. |
7 |
AdjustmentEventThe object of this class represents the adjustment event emitted by Adjustable objects. |
8 |
ComponentEventThe object of this class represents the change in the state of a window. |
9 |
ContainerEventThe object of this class represents the change in the state of a window. |
10 |
MouseMotionEventThe object of this class represents the change in the state of a window. |
11 |
PaintEventThe object of this class represents the change in the state of a window. |