We use Java Applet to track all mouse events and return the coordinates of the cursor.
First, we will talk about the interfaces that we have used.
MouseListener and MouseEventListener.
The Listener gets notified when an event occurs.
The various methods that we have used are mouse clicked - when we click the button we use this method.
Mouse entered - when the cursor enters the window this function comes into action.
Mouse exited - refers to us when the cursor leaves the window.
Mouse pressed - when we click the button
Mouse dragged - is to track the cursor when we have clicked the mouse and moved it.
The getX and getY return the position of the cursor in the window at the x and y-axis respectively.
Submitted by Anirban Chatterjee (anirban20)
Download packets of source code on Coders Packet