EventObject Class in Java

0
73
Spread the love
  • 23
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    160
    Shares

EventObject class in Java

Eventobject serves as a superclass for all events objects used by the Java AWT event model and the JavaBeans event model. This class defines a very generic type of event; it is extended by the more specific event classes in the java.awt, java.awt.event, and java.beans packages.

The class is named EventObject to avoid confusion with java.awt.Event, which was used to represent events in the old Java 1.0 event model.

The only common feature shared by all events is a source object, which is the object that in some way “generated” the event. The source object is passed to the EventObject() constructor, and is returned by the getsource() method.

The Class Structure of the EventObject is given as

public class java.util.EventObject extends java.lang.Object implements java.io.Serializable {
// Public Constructor
public Eventobject(Object source);
// Protected Instance Variables
protected transient Object source;
// Public Instance Methods
public Object getSource();
public String toString();// Overrides Object
}

The details of the class structure are given as follows:

protected transient Object source;

protected transient Object source represents the object that generated this EventObject.

public EventObject(Object source);

public EventObject(Object source) constructor creates an EventObject whose source is the given object.

Parameter
source – The object that generated this EventObject.

public Object getSource();

public Object getSource() method returns the object that is the source of this EventObject.

This method returns the object that generated this EventObject.

public String toString();

public String toString() method returns a string representation of this EventObject.

This method returns a string that represents this EventObject.

Apart from these EventObject class also has inherited methods from class- Object. They are as follows:

  • clone()
  • finalize()
  • hashCode()
  • notifyAll()
  • wait()
  • wait(long, int)
  • equals()
  • getClass()
  • notify()
  • wait(long)
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 23
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    160
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here