Create mouse event using Robot class in Java

Description

The following code shows how to create mouse event using Robot class.

Example


//  ww w  .  j  av a2  s .c  o  m
import java.awt.Robot;
import java.awt.event.InputEvent;

public class Main {
  public static void main(String[] args) throws Exception {
    Robot robot = new Robot();

    robot.mouseMove(200, 200);

    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.mouseWheel(-100);
  }
}




















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization