Class MouseLiberalAdapter
java.lang.Object
java.awt.event.MouseAdapter
com.github.lgooddatepicker.zinternaltools.MouseLiberalAdapter
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,MouseWheelListener
,EventListener
MouseLiberalAdapter.
This class extends the MouseAdapter class, to include two additional events. The added events are
the mouseLiberalClick() and the mouseLiberalDoubleClick(). By default, the mouseClick() event in
the MouseAdapter has a limitation. The mouseClick() event cannot register a click if the mouse
pointer moves even slightly, between the mouse press and mouse release events. By contrast, the
mouseLiberalClick() will register a "liberal mouse click" even if the mouse moves (by any amount)
during the click event, as long as the mouse pointer does not leave the boundaries of the
component which is generating the mouse events. (This "liberal mouse click" behavior duplicates
the "actionPerformed()" functionality that exists in the JButton class.)
Note: This class is frequently used to detect clicks in a JLabel, but it can be used in any swing
component that will accept a MouseAdapter.
Using this class is similar to using the MouseAdapter class. (See also: The MouseAdapter
javadocs.) To use this class, you would extend this class and override any (non-final) event
methods that are of interest.
The original MouseAdapter functions have been marked as final, and cannot be overridden. However,
the class still provides all the original functions (with slightly modified function names). The
two new functions are also provided: mouseLiberalClick() and mouseLiberalDoubleClick(). A usage
example is shown below.
Usage example:
JLabel labelSingleClick = new JLabel("Single click me.");
JLabel labelDoubleClick = new JLabel("Double click me.");
labelSingleClick.addMouseListener(new MouseLiberalAdapter() {
public void mouseLiberalClick(MouseEvent e) {
JOptionPane.showMessageDialog(null, "Single click detected.");
}
});
labelDoubleClick.addMouseListener(new MouseLiberalAdapter() {
public void mouseLiberalDoubleClick(MouseEvent e) {
JOptionPane.showMessageDialog(null, "Double click detected.");
}
});
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
mouseClick, Override this function to catch standard mouse click events.final void
mouseClicked, Final function.void
mouseDrag, Override this function to catch standard mouse drag events.final void
mouseDragged, Final function.void
mouseEnter, Override this function to catch standard mouse enter events.final void
mouseEntered, Final function.void
mouseExit, Override this function to catch standard mouse exit events.final void
mouseExited, Final function.void
mouseLiberalClick, Override this function to catch liberal single click events.void
mouseLiberalDoubleClick, Override this function to catch liberal double click events.void
mouseMove, Override this function to catch standard mouse move events.final void
mouseMoved, Final function.void
mousePress, Override this function to catch standard mouse press events.final void
mousePressed, Final function.void
mouseRelease, Override this function to catch standard mouse release events.final void
mouseReleased, Final function.void
mouseWheelMove, Override this function to catch standard mouse wheel move events.final void
mouseWheelMoved, Final function.
-
Constructor Details
-
MouseLiberalAdapter
public MouseLiberalAdapter()
-
-
Method Details
-
mouseLiberalClick
mouseLiberalClick, Override this function to catch liberal single click events. Note: The mouse event which is passed to this function will be the mouse event that was received from the "mouseRelease" event at the end of the liberal single click. -
mouseLiberalDoubleClick
mouseLiberalDoubleClick, Override this function to catch liberal double click events. Note: The mouse event which is passed to this function will be the mouse event that was received from the "mouseRelease" event at the end of the liberal double click. -
mouseClick
mouseClick, Override this function to catch standard mouse click events. -
mousePress
mousePress, Override this function to catch standard mouse press events. -
mouseRelease
mouseRelease, Override this function to catch standard mouse release events. -
mouseEnter
mouseEnter, Override this function to catch standard mouse enter events. -
mouseExit
mouseExit, Override this function to catch standard mouse exit events. -
mouseWheelMove
mouseWheelMove, Override this function to catch standard mouse wheel move events. -
mouseDrag
mouseDrag, Override this function to catch standard mouse drag events. -
mouseMove
mouseMove, Override this function to catch standard mouse move events. -
mousePressed
mousePressed, Final function. Handles mouse pressed events.- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classMouseAdapter
-
mouseReleased
mouseReleased, Final function. Handles mouse released events. This function also detects liberal single clicks, and liberal double clicks.- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classMouseAdapter
-
mouseEntered
mouseEntered, Final function. Handles mouse entered events.- Specified by:
mouseEntered
in interfaceMouseListener
- Overrides:
mouseEntered
in classMouseAdapter
-
mouseExited
mouseExited, Final function. Handles mouse exited events.- Specified by:
mouseExited
in interfaceMouseListener
- Overrides:
mouseExited
in classMouseAdapter
-
mouseClicked
mouseClicked, Final function. Handles mouse clicked events.- Specified by:
mouseClicked
in interfaceMouseListener
- Overrides:
mouseClicked
in classMouseAdapter
-
mouseWheelMoved
mouseWheelMoved, Final function. Handles mouse wheel moved events.- Specified by:
mouseWheelMoved
in interfaceMouseWheelListener
- Overrides:
mouseWheelMoved
in classMouseAdapter
-
mouseDragged
mouseDragged, Final function. Handles mouse dragged events.- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classMouseAdapter
-
mouseMoved
mouseMoved, Final function. Handles mouse moved events.- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classMouseAdapter
-