- SWING Tutorial
- SWING - Home
- SWING - Overview
- SWING - Environment
- SWING - Controls
- SWING - Event Handling
- SWING - Event Classes
- SWING - Event Listeners
- SWING - Event Adapters
- SWING - Layouts
- SWING - Menu
- SWING - Containers
- SWING Useful Resources
- SWING - Quick Guide
- SWING - Useful Resources
- SWING - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
SWING - Event Classes
Event classes represent the event. Java provides various Event classes, however, only those which are more frequently used will be discussed.
EventObject Class
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
Following is the declaration for java.util.EventObject class −
public class EventObject extends Object implements Serializable
Field
Following are the fields for java.util.EventObject class −
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 | 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. |