Awt 简明教程
AWT Event Classes
事件类表示事件。Java 为我们提供了各种事件类,但我们将讨论那些使用频率较高的事件类。
The Event classes represent the event. Java provides us various Event classes but we will discuss those which are more frequently used.
EventObject class
它是从所有事件状态对象都应从中衍生的根类。所有事件都使用对对象 source 的引用构造, 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 — The object on which the Event initially occurred.
Class constructors
S.N. |
Constructor & Description |
1 |
*EventObject(Object source) * Constructs a prototypical Event. |
Class methods
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. |
Methods inherited
该类继承以下类的各种方法:
This class inherits methods from the following classes:
-
java.lang.Object
AWT Event Classes:
以下是常用的事件类的列表。
Following is the list of commonly used 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. |