Awt 简明教程

AWT Event Listeners

事件侦听器表示负责处理事件的接口。Java 为我们提供了各种事件侦听器类,但我们将讨论那些最常使用的类。每个事件侦听器方法都有一个参数,该参数作为 EventObject 类的子类的对象。例如,鼠标事件侦听器方法将接受 MouseEvent 的实例,而 MouseEvent 派生自 EventObject。

The Event listener represent the interfaces responsible to handle events. Java provides us various Event listener classes but we will discuss those which are more frequently used. Every method of an event listener method has a single argument as an object which is subclass of EventObject class. For example, mouse event listener methods will accept instance of MouseEvent, where MouseEvent derives from EventObject.

EventListner interface

这是一个标记接口,每个侦听器接口都必须对其进行扩展。此类在 java.util 包中定义。

It is a marker interface which every listener interface has to extend.This class is defined in java.util package.

Class declaration

以下是 java.util.EventListener 接口的声明:

Following is the declaration for java.util.EventListener interface:

public interface EventListener

AWT Event Listener Interfaces:

以下是常用事件侦听器的列表。

Following is the list of commonly used event listeners.

Sr. No.

Control & Description

1

ActionListener This interface is used for receiving the action events.

2

ComponentListener This interface is used for receiving the component events.

3

ItemListener This interface is used for receiving the item events.

4

KeyListener This interface is used for receiving the key events.

5

MouseListener This interface is used for receiving the mouse events.

6

TextListener This interface is used for receiving the text events.

7

WindowListener This interface is used for receiving the window events.

8

AdjustmentListener This interface is used for receiving the adjusmtent events.

9

ContainerListener This interface is used for receiving the container events.

10

MouseMotionListener This interface is used for receiving the mouse motion events.

11

FocusListener This interface is used for receiving the focus events.