public class FormMouseEvent extends FormEvent
A specialized event class for reporting events related to mouse actions.
Events of this type are passed to components that have registered themselves
as mouse listeners at input components. This way listeners get notified, for
instance, if the mouse is clicked, released, or moved within an input
components. The type
property can be queried to find out which mouse
action was performed. The coordinates of the mouse cursor (relative to the
origin of the source component) are also available. Further, the affected
mouse button and the status of special modifier keys (like SHIFT or
ALT) are available.
Mouse events are more low-level. In typical controller classes for input forms it is rarely necessary to react on specific mouse actions. In most cases action or change events are more appropriate. An exception can be double-click events, which are only available through a mouse listener.
FormMouseEvent
is derived from FormEvent
and thus provides
access to the ComponentHandler
and the name of the component that
triggered this event. Nevertheless, it is possible to register a mouse
listener at non-input components, e.g. windows. In this case, the handler
and name
properties are undefined.
Modifier and Type | Class and Description |
---|---|
static class |
FormMouseEvent.Type
An enumeration class defining constants for the possible mouse actions
that can trigger a
FormMouseEvent . |
Modifier and Type | Field and Description |
---|---|
static int |
BUTTON1
Constant for the mouse button 1.
|
static int |
BUTTON2
Constant for the mouse button 2.
|
static int |
BUTTON3
Constant for the mouse button 3.
|
static int |
NO_BUTTON
Constant for an undefined mouse button.
|
source
Constructor and Description |
---|
FormMouseEvent(Object source,
ComponentHandler<?> handler,
String name,
FormMouseEvent.Type t,
int xp,
int yp,
int btn,
Collection<Modifiers> mods)
Creates a new instance of
FormMouseEvent and initializes all its
properties. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
This base implementation tests the handler and name
properties.
|
int |
getButton()
Returns the index of the mouse button affected by this event.
|
Set<Modifiers> |
getModifiers()
Returns a set with
Modifiers representing the special modifier
keys that were pressed when the mouse event occurred. |
FormMouseEvent.Type |
getType()
Returns the type of this event.
|
int |
getX()
Returns the X position of the mouse relative to the origin of the
component that caused this event.
|
int |
getY()
Returns the Y position of the mouse relative to the origin of the
component that caused this event.
|
int |
hashCode()
Returns a hash code for this object.
|
String |
toString()
Returns a string representation of this object.
|
getHandler, getName
getSource
public static final int BUTTON1
getButton()
can be checked with this constant.public static final int BUTTON2
getButton()
can be checked with this constant.public static final int BUTTON3
getButton()
can be checked with this constant.public static final int NO_BUTTON
getButton()
if the event is not related to a button.public FormMouseEvent(Object source, ComponentHandler<?> handler, String name, FormMouseEvent.Type t, int xp, int yp, int btn, Collection<Modifiers> mods)
FormMouseEvent
and initializes all its
properties.source
- the source of this event (this is typically the original,
platform-specific event this object was created from)handler
- the ComponentHandler
of the input component that
caused this eventname
- the name of the input component that caused this eventt
- the type of this event (must not be null)xp
- the x position of the mouse cursoryp
- the y position of the mouse cursorbtn
- the index of the affected buttonmods
- a set with modifier keys (may be empty or null)IllegalArgumentException
- if a required parameter is missingpublic FormMouseEvent.Type getType()
public int getX()
public int getY()
public int getButton()
BUTTONx
constants. It indicates which button
was pressed or released. If the event is not related to a mouse button,
result is NO_BUTTON
.public Set<Modifiers> getModifiers()
Modifiers
representing the special modifier
keys that were pressed when the mouse event occurred. This information
can be used to distinguish enhanced mouse gestures, e.g. SHIFT+CLICK for
text selection. The set returned by this method cannot be modified.public String toString()
toString
in class EventObject
public int hashCode()
public boolean equals(Object obj)
Copyright © 2016 The JGUIraffe Team. All rights reserved.