|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.EventObject
java.awt.AWTEvent
java.awt.event.ComponentEvent
java.awt.event.InputEvent
java.awt.event.MouseEvent
java.awt.event.MouseWheelEvent
public class MouseWheelEvent
This event is generated for a mouse wheel rotation. The wheel (the middle mouse button on most modern mice) can be rotated towards or away from the user, and is often used for scrolling.
Because of the special use for scrolling components, MouseWheelEvents often affect a different component than the one located at the point of the event. If the component under the mouse cursor does not accept wheel events, the event is passed to the first ancestor container which does. This is often a ScrollPane, which knows how to scroll. If an AWT component is built from a native widget that knows how to use mouse wheel events, that component will consume the event.
The two most common scroll types are "units" (lines at a time) or "blocks" (pages at a time). The initial setting is taken from the platform, although the user can adjust the setting at any time.
MouseWheelListener
,
ScrollPane
,
ScrollPane.setWheelScrollingEnabled(boolean)
,
JScrollPane
,
JScrollPane.setWheelScrollingEnabled(boolean)
,
Serialized FormField Summary | |
---|---|
static int |
WHEEL_BLOCK_SCROLL
Indicates scrolling by blocks (pages). |
static int |
WHEEL_UNIT_SCROLL
Indicates scrolling by units (lines). |
Fields inherited from class java.awt.event.MouseEvent |
---|
BUTTON1, BUTTON2, BUTTON3, MOUSE_CLICKED, MOUSE_DRAGGED, MOUSE_ENTERED, MOUSE_EXITED, MOUSE_FIRST, MOUSE_LAST, MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED, MOUSE_WHEEL, NOBUTTON |
Fields inherited from class java.awt.event.InputEvent |
---|
ALT_DOWN_MASK, ALT_GRAPH_DOWN_MASK, ALT_GRAPH_MASK, ALT_MASK, BUTTON1_DOWN_MASK, BUTTON1_MASK, BUTTON2_DOWN_MASK, BUTTON2_MASK, BUTTON3_DOWN_MASK, BUTTON3_MASK, CTRL_DOWN_MASK, CTRL_MASK, META_DOWN_MASK, META_MASK, SHIFT_DOWN_MASK, SHIFT_MASK |
Fields inherited from class java.awt.event.ComponentEvent |
---|
COMPONENT_FIRST, COMPONENT_HIDDEN, COMPONENT_LAST, COMPONENT_MOVED, COMPONENT_RESIZED, COMPONENT_SHOWN |
Fields inherited from class java.util.EventObject |
---|
source |
Constructor Summary | |
---|---|
MouseWheelEvent(Component source,
int id,
long when,
int modifiers,
int x,
int y,
int clickCount,
boolean popupTrigger,
int scrollType,
int scrollAmount,
int wheelRotation)
Initializes a new instance of MouseWheelEvent with the
specified information. |
Method Summary | |
---|---|
int |
getScrollAmount()
Returns the number of units to scroll in response to this event. |
int |
getScrollType()
This method returns the scrolling pattern this event requests. |
int |
getUnitsToScroll()
This is a convenience method which aids in a common listener for scrolling a scrollpane (although this is already built into ScrollPane and JScrollPane). |
int |
getWheelRotation()
Gets the number of "clicks" the wheel was rotated. |
String |
paramString()
Returns a string identifying this event. |
Methods inherited from class java.awt.event.MouseEvent |
---|
getButton, getClickCount, getLocationOnScreen, getMouseModifiersText, getPoint, getX, getXOnScreen, getY, getYOnScreen, isPopupTrigger, translatePoint |
Methods inherited from class java.awt.event.InputEvent |
---|
consume, getModifiers, getModifiersEx, getModifiersExText, getWhen, isAltDown, isAltGraphDown, isConsumed, isControlDown, isMetaDown, isShiftDown |
Methods inherited from class java.awt.event.ComponentEvent |
---|
getComponent |
Methods inherited from class java.awt.AWTEvent |
---|
getID, setSource, toString |
Methods inherited from class java.util.EventObject |
---|
getSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int WHEEL_UNIT_SCROLL
getScrollType()
,
Constant Field Valuespublic static final int WHEEL_BLOCK_SCROLL
getScrollType()
,
Constant Field ValuesConstructor Detail |
---|
public MouseWheelEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger, int scrollType, int scrollAmount, int wheelRotation)
MouseWheelEvent
with the
specified information. Note that an invalid id leads to unspecified
results.
source
- the source of the eventid
- the event idwhen
- the timestamp of when the event occurredmodifiers
- any modifier bits for this eventx
- the X coordinate of the mouse pointy
- the Y coordinate of the mouse pointclickCount
- the number of mouse clicks for this eventpopupTrigger
- true if this event triggers a popup menuscrollType
- one of WHEEL_UNIT_SCROLL
,
WHEEL_BLOCK_SCROLL
scrollAmount
- the number of units to scroll, ignored for block typewheelRotation
- the number of rotation "clicks"
IllegalArgumentException
- if source is nullMouseEvent.MouseEvent(Component, int, long, int, int, int, int,
boolean)
Method Detail |
---|
public int getScrollType()
WHEEL_UNIT_SCROLL
and WHEEL_BLOCK_SCROLL
.
Adjustable.getUnitIncrement()
,
Adjustable.getBlockIncrement()
,
Scrollable.getScrollableUnitIncrement(Rectangle, int, int)
,
Scrollable.getScrollableBlockIncrement(Rectangle, int, int)
public int getScrollAmount()
getScrollType()
public int getWheelRotation()
public int getUnitsToScroll()
This accounts for direction of scroll and amount of wheel movement, as interpreted by the platform settings.
getScrollType()
,
getScrollAmount()
,
MouseWheelListener
,
Adjustable
,
Adjustable.getUnitIncrement()
,
Scrollable
,
Scrollable.getScrollableUnitIncrement(Rectangle, int, int)
,
ScrollPane
,
ScrollPane.setWheelScrollingEnabled(boolean)
,
JScrollPane
,
JScrollPane.setWheelScrollingEnabled(boolean)
public String paramString()
super.paramString() + ",scrollType=WHEEL_" +
(getScrollType() == WHEEL_UNIT_SCROLL ? "UNIT" : "BLOCK")
+ "_SCROLL,scrollAmount=" + getScrollAmount() + ",wheelRotation="
+ getWheelRotation()
.
paramString
in class MouseEvent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |