- SPLessons

Swing Event Classes

Home > > Tutorial
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Swing Event Classes

Swing Event Classes

shape Description

Swing event classes play a major role in Swing applications and indicate the event. While developing an application based on the Swing technology developer can use more Swing classes depends on the requirement because Swing consists of more classes so it is a little bit hard to use all the classes in applications. Splessons will teach about commonly used classes.
EventObject class is base class and it can derive the exact behavior and state of the instance(object). It is available in java.util package. So, the syntax of the above class(java.util.EventObject) can be shown as follows. [java]public class EventObject extends Object implements Serializable[/java] Protected Object Source is the field of java.util.EventObject, and on which the only event will happen initially.This class consists of methods also and these methods will be inherited from the java.util.object.
It is the base of the AWTEvent and i can be derived from the java.awt package.The syntax declaration of the java.awt.AWTEvent can be indicated as follows. [java]public class AWTEvent extends EventObject[/java]
When user click on the button it will be performed. The syntax of the above class(java.awt.event.ActionEvent) can be shown as follows. [java]public class ActionEvent extends AWTEvent[/java]

Fields of ActionEvent

Methods of ActionEvent

Above methods will be inherited from the package such as java.awt.AWTEvent and java.lang.Object
The instance of WindowEvent will be activated when window is open or closed or terminated. The package of this class can be declared as java.awt.event.WindowEvent. The syntax of java.awt.event.WindowEvent can be written as follows. [java]public class WindowEvent extends ComponentEvent[/java]

Fields of WindowEvent

Methods of ActionEvent

The above methods will be inherited from the java.lang.object , java.awt.AWTEvent .
This event will be useful when the mouse is dragged or moved. This class will be available in java.awt.event.MouseMotionEvent . The syntax of this class can be written as  follows. [java]public class MouseMotionEvent extends InputEvent[/java] The above all the methods inherited from java.awt.event.InputEvent , java.awt.event.ComponentEvent .
This class will be use full to update or paint the methods and it will be available in the package of java.awt.event and can be declare as java.awt.event.PaintEvent .The syntax can be written as follows. [java]public class PaintEvent extends ComponentEvent[/java]

Fields of PaintEvent

Methods of PaintEvent

The above methods will be inherited from the java.awt.ComponentEvent , java.awt.AWTEvent, java.lang.Object

Summary

shape Points

  • java.io.Serializable interface needs to be implemented by the class.
  • int getID() is a method of AWTEvent i.e indicates the type of the event.

Swings - Related Information
Swing Controls
Swing Events
Swing Event Listeners
Swing Events Adapters
Swing Menu