RosettaCodeData/Task/Simulate-input-Mouse/Java/simulate-input-mouse-1.java
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

6 lines
414 B
Java

Point p = component.getLocation();
Robot robot = new Robot();
robot.mouseMove(p.getX(), p.getY()); //you may want to move a few pixels closer to the center by adding to these values
robot.mousePress(InputEvent.BUTTON1_MASK); //BUTTON1_MASK is the left button,
//BUTTON2_MASK is the middle button, BUTTON3_MASK is the right button
robot.mouseRelease(InputEvent.BUTTON1_MASK);