In java you can use the Robot Class to move the mouse and fire mouse clicks. While this is cool, it also "hijacks" the users mouse, so you cannot multitask.
What I want to do is make a "Fake" mouse that acts independently of the system's mouse cursor, and lives only inside my java applet. In this sense the applet would think it was being clicked by the mouse in various (x,y) positions (within the applet), however I can do whatever I want with the system mouse and it will not be affected.
I have seen programs that have accomplished this, I just have no idea where to begin. Perhaps I am just using the wrong terminology for this functionality.
Any suggestions on where to look would be much appreciated. -Thanks
What I want to do is make a "Fake" mouse that acts independently of the system's mouse cursor, and lives only inside my java applet.
Create a Runnable FakeMouse class that fires mouse clicks. Tony Depace provided the code, which I'm adding to the answer to help others.
MouseEvent aClick = new MouseEvent(this, MouseEvent.MOUSE_CLICKED,
System.currentTimeMillis(), 0, 10, 10, 1, false);
dispatchEvent(aClick);
Run the FakeMouse class in a thread in your Java applet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With