1 7 8 package java.awt.event; 9 10 import java.awt.Component ; 11 import sun.awt.DebugHelper; 12 13 70 71 public class MouseWheelEvent extends MouseEvent { 72 73 private static final DebugHelper dbg = DebugHelper.create(MouseWheelEvent .class); 74 75 81 public static final int WHEEL_UNIT_SCROLL = 0; 82 83 89 public static final int WHEEL_BLOCK_SCROLL = 1; 90 91 101 int scrollType; 102 103 111 int scrollAmount; 112 113 118 int wheelRotation; 119 120 122 154 public MouseWheelEvent (Component source, int id, long when, int modifiers, 155 int x, int y, int clickCount, boolean popupTrigger, 156 int scrollType, int scrollAmount, int wheelRotation) { 157 158 super(source, id, when, modifiers, x, y, clickCount, popupTrigger); 159 160 161 this.scrollType = scrollType; 162 this.scrollAmount = scrollAmount; 163 this.wheelRotation = wheelRotation; 164 165 if (dbg.on) { 166 dbg.println("MouseWheelEvent constructor"); 167 } 169 } 170 171 187 public int getScrollType() { 188 return scrollType; 189 } 190 191 201 public int getScrollAmount() { 202 return scrollAmount; 203 } 204 205 212 public int getWheelRotation() { 213 return wheelRotation; 214 } 215 216 263 public int getUnitsToScroll() { 264 return scrollAmount * wheelRotation; 265 } 266 267 273 public String paramString() { 274 String scrollTypeStr = null; 275 276 if (getScrollType() == WHEEL_UNIT_SCROLL) { 277 scrollTypeStr = "WHEEL_UNIT_SCROLL"; 278 } 279 else if (getScrollType() == WHEEL_BLOCK_SCROLL) { 280 scrollTypeStr = "WHEEL_BLOCK_SCROLL"; 281 } 282 else { 283 scrollTypeStr = "unknown scroll type"; 284 } 285 return super.paramString()+",scrollType="+scrollTypeStr+ 286 ",scrollAmount="+getScrollAmount()+",wheelRotation="+ 287 getWheelRotation(); 288 } 289 } 290 291 | Popular Tags |