// Called when the mouse wheel is rotated public void onMouseWheelMoved(MouseWheelEvent e) { // If the wheel rotation is negative it means that it is moved forward. // Set move direction = forward, if wheel is moved forward. // Otherwise, set move direction = backward moveDirection = (e.getWheelRotation() < 0) ? 1 : -1; // Set the amount to move = absolute wheel rotation amount * 5 (speed) // Here 5 means 5 pixels per wheel rotation step. The higher value, the // more speed moveAmount += Math.abs(e.getWheelRotation()) * 5; }