The Mouse Event Class

There are seven types of mouse events. The Mouse Event class defines the following
integer constants that can be used to identify them:

Here, src is a reference to the component that generated the event. The type of the event is specified by type. The system time at which the mouse event occurred is passed in to hen. The modifiers argument indicates which modifiers were pressed when a mouse event occurred. The'coordinates of the mouse are passed in x and y. The click count is passed in clicks. The triggers pup flag indicates jf this event causes a pop-up menu to appear on this platform. . The most commonly used methods in this class are  and  These return the X and Y coordinates of the mouse when the event occurred. Their forms are shown her

int getX()
int getY():
Alternatively   can use the get Point() method to obtain the coordinates of the
mouse. It is shown here:
Point get Poirt
It returns a Point object that contains the X,Y coordinates in its integer members: x and y.
The translatePoinH ) method changes the location of the event. Its form is shown here:
void translate Point(int x, inty)
Here, the arguments x and y  Ire added to the coordinates  event.

The' Text Event 'Class

Instances of this class describe text events. These are generated by text fields and text areas when characters are entered by a user or program. Text Event defines the integer constant TEXT_VALUE_CHANGED. The one constructor for this class is shown here: Text Event(Object src, int type)
Here, src is a reference to the object that generated this event. The type of the event is . specified by type. The Text Event object does not include the characters currently in the text component  that generated the event. Instead, your program must use other methods associate ed with the text component to retrieve that information. This operation differs from other event objects discussed in this section. For this reason, no methods are discussed here for the Text Event class. Think of a text event notification as a signal  listener that it should retrieve information from a specific text component.

Share This