Java Swing Tutorial - Java Robot.mouseWheel(int wheelAmt)








Syntax

Robot.mouseWheel(int wheelAmt) has the following syntax.

public void mouseWheel(int wheelAmt)

Example

In the following code shows how to use Robot.mouseWheel(int wheelAmt) method.

//from w ww . j  a  v a 2  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);
  }
}