1 /* 2 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.event; 27 28 import java.awt.Component; 29 30 import javax.tools.annotation.GenerateNativeHeader; 31 32 /** 33 * An event which indicates that the mouse wheel was rotated in a component. 34 * <P> 35 * A wheel mouse is a mouse which has a wheel in place of the middle button. 36 * This wheel can be rotated towards or away from the user. Mouse wheels are 37 * most often used for scrolling, though other uses are possible. 38 * <P> 39 * A MouseWheelEvent object is passed to every <code>MouseWheelListener</code> 40 * object which registered to receive the "interesting" mouse events using the 41 * component's <code>addMouseWheelListener</code> method. Each such listener 42 * object gets a <code>MouseEvent</code> containing the mouse event. 43 * <P> 44 * Due to the mouse wheel's special relationship to scrolling Components, 45 * MouseWheelEvents are delivered somewhat differently than other MouseEvents. 46 * This is because while other MouseEvents usually affect a change on 47 * the Component directly under the mouse 48 * cursor (for instance, when clicking a button), MouseWheelEvents often have 49 * an effect away from the mouse cursor (moving the wheel while 50 * over a Component inside a ScrollPane should scroll one of the 82 * The {@link #getWheelRotation} method returns the integer number 83 * of "clicks" corresponding to the number of notches by which the wheel was 84 * rotated. In addition to this method, the <code>MouseWheelEvent</code> 85 * class provides the {@link #getPreciseWheelRotation} method which returns 86 * a double number of "clicks" in case a partial rotation occurred. 87 * The {@link #getPreciseWheelRotation} method is useful if a mouse supports 88 * a high-resolution wheel, such as a freely rotating wheel with no 89 * notches. Applications can benefit by using this method to process 90 * mouse wheel events more precisely, and thus, making visual perception 91 * smoother. 92 * 93 * @author Brent Christian 94 * @see MouseWheelListener 95 * @see java.awt.ScrollPane 96 * @see java.awt.ScrollPane#setWheelScrollingEnabled(boolean) 97 * @see javax.swing.JScrollPane 98 * @see javax.swing.JScrollPane#setWheelScrollingEnabled(boolean) 99 * @since 1.4 100 */ 101 102 /* No native methods here, but the constants are needed in the supporting JNI code */ 103 @GenerateNativeHeader 104 public class MouseWheelEvent extends MouseEvent { 105 106 /** 107 * Constant representing scrolling by "units" (like scrolling with the 108 * arrow keys) 109 * 110 * @see #getScrollType 111 */ 112 public static final int WHEEL_UNIT_SCROLL = 0; 113 114 /** 115 * Constant representing scrolling by a "block" (like scrolling 116 * with page-up, page-down keys) 117 * 118 * @see #getScrollType 119 */ 120 public static final int WHEEL_BLOCK_SCROLL = 1; 121 122 /** 123 * Indicates what sort of scrolling should take place in response to this 124 * event, based on platform settings. Legal values are: 125 * <ul> 126 * <li> WHEEL_UNIT_SCROLL 127 * <li> WHEEL_BLOCK_SCROLL 128 * </ul> 129 * 130 * @see #getScrollType 131 */ 132 int scrollType; 133 134 /** 135 * Only valid for scrollType WHEEL_UNIT_SCROLL. 136 * Indicates number of units that should be scrolled per 137 * click of mouse wheel rotation, based on platform settings. 138 * 139 * @see #getScrollAmount 140 * @see #getScrollType | 1 /* 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.event; 27 28 import java.awt.Component; 29 30 import java.lang.annotation.Native; 31 32 /** 33 * An event which indicates that the mouse wheel was rotated in a component. 34 * <P> 35 * A wheel mouse is a mouse which has a wheel in place of the middle button. 36 * This wheel can be rotated towards or away from the user. Mouse wheels are 37 * most often used for scrolling, though other uses are possible. 38 * <P> 39 * A MouseWheelEvent object is passed to every <code>MouseWheelListener</code> 40 * object which registered to receive the "interesting" mouse events using the 41 * component's <code>addMouseWheelListener</code> method. Each such listener 42 * object gets a <code>MouseEvent</code> containing the mouse event. 43 * <P> 44 * Due to the mouse wheel's special relationship to scrolling Components, 45 * MouseWheelEvents are delivered somewhat differently than other MouseEvents. 46 * This is because while other MouseEvents usually affect a change on 47 * the Component directly under the mouse 48 * cursor (for instance, when clicking a button), MouseWheelEvents often have 49 * an effect away from the mouse cursor (moving the wheel while 50 * over a Component inside a ScrollPane should scroll one of the 82 * The {@link #getWheelRotation} method returns the integer number 83 * of "clicks" corresponding to the number of notches by which the wheel was 84 * rotated. In addition to this method, the <code>MouseWheelEvent</code> 85 * class provides the {@link #getPreciseWheelRotation} method which returns 86 * a double number of "clicks" in case a partial rotation occurred. 87 * The {@link #getPreciseWheelRotation} method is useful if a mouse supports 88 * a high-resolution wheel, such as a freely rotating wheel with no 89 * notches. Applications can benefit by using this method to process 90 * mouse wheel events more precisely, and thus, making visual perception 91 * smoother. 92 * 93 * @author Brent Christian 94 * @see MouseWheelListener 95 * @see java.awt.ScrollPane 96 * @see java.awt.ScrollPane#setWheelScrollingEnabled(boolean) 97 * @see javax.swing.JScrollPane 98 * @see javax.swing.JScrollPane#setWheelScrollingEnabled(boolean) 99 * @since 1.4 100 */ 101 102 public class MouseWheelEvent extends MouseEvent { 103 104 /** 105 * Constant representing scrolling by "units" (like scrolling with the 106 * arrow keys) 107 * 108 * @see #getScrollType 109 */ 110 @Native public static final int WHEEL_UNIT_SCROLL = 0; 111 112 /** 113 * Constant representing scrolling by a "block" (like scrolling 114 * with page-up, page-down keys) 115 * 116 * @see #getScrollType 117 */ 118 @Native public static final int WHEEL_BLOCK_SCROLL = 1; 119 120 /** 121 * Indicates what sort of scrolling should take place in response to this 122 * event, based on platform settings. Legal values are: 123 * <ul> 124 * <li> WHEEL_UNIT_SCROLL 125 * <li> WHEEL_BLOCK_SCROLL 126 * </ul> 127 * 128 * @see #getScrollType 129 */ 130 int scrollType; 131 132 /** 133 * Only valid for scrollType WHEEL_UNIT_SCROLL. 134 * Indicates number of units that should be scrolled per 135 * click of mouse wheel rotation, based on platform settings. 136 * 137 * @see #getScrollAmount 138 * @see #getScrollType |