AWT Event Classes - AWT (Abstract Window Toolkit)

What is the use of AWT event classes?

Event classes are used for representing an event. Java offers several Event classes but we will discuss only most frequently used ones.

EventObject class

Eventobject is the root class from which all the event state objects are derived. All the Events will be constructed with a reference to the object i.e; source. Source is logically believed to be the object upon which the Event in question initially occurred. This class will be defined in java.util package.

Class declaration

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

Field

Below are the fields for java.util.EventObject class:

  • protected Object source -- Object on which the Event initially occurred.

Class constructors

S.N.

Constructor & Description

1

EventObject(Object source)

This will construct a prototypical Event.

Class methods

S.N.

Method & Description

1

Object getSource()

Object on which the Event initially occurred.

2

String toString()

This will return a String representation of this EventObject.

Methods inherited

This class inherits methods from below classes:

  • java.lang.Object

AWT Event Classes:

Below is the list of commonly used event classes.

Sr. No.

Control & Description

1

AWTEvent

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

2

ActionEvent

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

3

InputEvent

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

4

KeyEvent

Key event will be generated upon entering the character.

5

MouseEvent

This event will indicate a mouse action occurred in a component.

6

TextEvent

Object of this class will represnt the text events.

7

WindowEvent

Object of this class will represnt a change in the state of a window.

8

AdjustmentEvent

Object of this class will represnt the adjustment event emitted by Adjustable objects.

9

ComponentEvent

Object of this class will represnt the change in state of a window.

10

ContainerEvent

Object of this class will represnt the change in state of a window.

11

MouseMotionEvent

Object of this class will represnt the change in state of a window.

12

PaintEvent

Object of this class will represnt the change in state of a window.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

AWT (Abstract Window Toolkit) Topics