I want to simulate a mousePressed event in Java, I found out that I can use the Robot
class for this, and it works, but only in Windows and not in Mac OS X.
Does anyone know of an alternative way to simulate a mousePressed
event?
This is the code I used:
Robot robot = new Robot();
robot.mousePress(InputEvent.BUTTON1_MASK);
If you want to simulate the click action on a JButton
you can invoke the doClick
method, take a look here. Otherwise, maybe this similar question can help you.
Hope this helps.