Package adams.gui.core
Class MouseUtils
- java.lang.Object
-
- adams.gui.core.MouseUtils
-
public class MouseUtils extends Object
Helper class for mouse events.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static StringMODIFIER_ALTstatic StringMODIFIER_ALT_GRAPHstatic StringMODIFIER_CTRLstatic StringMODIFIER_METAstatic StringMODIFIER_SHIFT
-
Constructor Summary
Constructors Constructor Description MouseUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanhasNoModifierKey(MouseEvent e)Checks whether no modified key is pressed.static booleanisDoubleClick(MouseEvent e)Checks whether the mouse event is a double-click event (with the left mouse button).static booleanisLeftClick(MouseEvent e)Checks whether the mouse event is a left-click event.static booleanisLeftDown(MouseEvent e)Checks whether the left mouse button is down.static booleanisMiddleClick(MouseEvent e)Checks whether the mouse event is a middle/wheel-click event.static booleanisMiddleDown(MouseEvent e)Checks whether the middle mouse button is down.static booleanisPrintScreenClick(MouseEvent e)Checks whether the mouse event is a "print screen" event: Alt+Shift+Left-Click.static booleanisRightClick(MouseEvent e)Checks whether the mouse event is a right-click event.static booleanisRightDown(MouseEvent e)Checks whether the right mouse button is down.static List<String>modifiersToStr(int modifiers)Turns the extended modifiers associated with a mouse event to a list of strings.static List<String>modifiersToStr(MouseEvent e)Turns the extended modifiers associated with this mouse event to a list of strings.static voidsetDefaultCursor(Component comp)Sets the default cursor for the specified component.static voidsetWaitCursor(Component comp)Sets the wait cursor for the specified component.
-
-
-
Field Detail
-
MODIFIER_SHIFT
public static final String MODIFIER_SHIFT
- See Also:
- Constant Field Values
-
MODIFIER_CTRL
public static final String MODIFIER_CTRL
- See Also:
- Constant Field Values
-
MODIFIER_META
public static final String MODIFIER_META
- See Also:
- Constant Field Values
-
MODIFIER_ALT
public static final String MODIFIER_ALT
- See Also:
- Constant Field Values
-
MODIFIER_ALT_GRAPH
public static final String MODIFIER_ALT_GRAPH
- See Also:
- Constant Field Values
-
-
Method Detail
-
isLeftClick
public static boolean isLeftClick(MouseEvent e)
Checks whether the mouse event is a left-click event. Ctrl/Alt/Shift are allowed.- Parameters:
e- the event- Returns:
- true if a left-click event
-
isLeftDown
public static boolean isLeftDown(MouseEvent e)
Checks whether the left mouse button is down. Ctrl/Alt/Shift are allowed.- Parameters:
e- the event- Returns:
- true if left button down
-
isDoubleClick
public static boolean isDoubleClick(MouseEvent e)
Checks whether the mouse event is a double-click event (with the left mouse button). Ctrl/Alt/Shift are allowed.- Parameters:
e- the event- Returns:
- true if a double-click event
-
isMiddleClick
public static boolean isMiddleClick(MouseEvent e)
Checks whether the mouse event is a middle/wheel-click event. Ctrl/Alt/Shift are allowed.- Parameters:
e- the event- Returns:
- true if a middle/wheel-click event
-
isMiddleDown
public static boolean isMiddleDown(MouseEvent e)
Checks whether the middle mouse button is down. Ctrl/Alt/Shift are allowed.- Parameters:
e- the event- Returns:
- true if middle/wheel down
-
isRightClick
public static boolean isRightClick(MouseEvent e)
Checks whether the mouse event is a right-click event. Alt+Left-Click is also interpreted as right-click.- Parameters:
e- the event- Returns:
- true if a right-click event
-
isRightDown
public static boolean isRightDown(MouseEvent e)
Checks whether the right mouse button is down.- Parameters:
e- the event- Returns:
- true if right button down
-
isPrintScreenClick
public static boolean isPrintScreenClick(MouseEvent e)
Checks whether the mouse event is a "print screen" event: Alt+Shift+Left-Click.- Parameters:
e- the event- Returns:
- true if a "print screen" event
-
hasNoModifierKey
public static boolean hasNoModifierKey(MouseEvent e)
Checks whether no modified key is pressed.- Parameters:
e- the event- Returns:
- true if no modifier key pressed
-
setWaitCursor
public static void setWaitCursor(Component comp)
Sets the wait cursor for the specified component.- Parameters:
comp- the component to update
-
setDefaultCursor
public static void setDefaultCursor(Component comp)
Sets the default cursor for the specified component.- Parameters:
comp- the component to update
-
modifiersToStr
public static List<String> modifiersToStr(MouseEvent e)
Turns the extended modifiers associated with this mouse event to a list of strings.- Parameters:
e- the event to process- Returns:
- the generated list of human-readable modifiers
- See Also:
MODIFIER_SHIFT,MODIFIER_CTRL,MODIFIER_META,MODIFIER_ALT,MODIFIER_ALT_GRAPH
-
modifiersToStr
public static List<String> modifiersToStr(int modifiers)
Turns the extended modifiers associated with a mouse event to a list of strings.- Parameters:
modifiers- the modifiers to process- Returns:
- the generated list of human-readable modifiers
- See Also:
MODIFIER_SHIFT,MODIFIER_CTRL,MODIFIER_META,MODIFIER_ALT,MODIFIER_ALT_GRAPH
-
-