Class MouseLiberalAdapter

java.lang.Object
java.awt.event.MouseAdapter
com.github.lgooddatepicker.zinternaltools.MouseLiberalAdapter
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public abstract class MouseLiberalAdapter extends MouseAdapter
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 Details

    • MouseLiberalAdapter

      public MouseLiberalAdapter()
  • Method Details

    • mouseLiberalClick

      public void mouseLiberalClick(MouseEvent e)
      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

      public void mouseLiberalDoubleClick(MouseEvent e)
      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

      public void mouseClick(MouseEvent e)
      mouseClick, Override this function to catch standard mouse click events.
    • mousePress

      public void mousePress(MouseEvent e)
      mousePress, Override this function to catch standard mouse press events.
    • mouseRelease

      public void mouseRelease(MouseEvent e)
      mouseRelease, Override this function to catch standard mouse release events.
    • mouseEnter

      public void mouseEnter(MouseEvent e)
      mouseEnter, Override this function to catch standard mouse enter events.
    • mouseExit

      public void mouseExit(MouseEvent e)
      mouseExit, Override this function to catch standard mouse exit events.
    • mouseWheelMove

      public void mouseWheelMove(MouseWheelEvent e)
      mouseWheelMove, Override this function to catch standard mouse wheel move events.
    • mouseDrag

      public void mouseDrag(MouseEvent e)
      mouseDrag, Override this function to catch standard mouse drag events.
    • mouseMove

      public void mouseMove(MouseEvent e)
      mouseMove, Override this function to catch standard mouse move events.
    • mousePressed

      public final void mousePressed(MouseEvent e)
      mousePressed, Final function. Handles mouse pressed events.
      Specified by:
      mousePressed in interface MouseListener
      Overrides:
      mousePressed in class MouseAdapter
    • mouseReleased

      public final void mouseReleased(MouseEvent e)
      mouseReleased, Final function. Handles mouse released events. This function also detects liberal single clicks, and liberal double clicks.
      Specified by:
      mouseReleased in interface MouseListener
      Overrides:
      mouseReleased in class MouseAdapter
    • mouseEntered

      public final void mouseEntered(MouseEvent e)
      mouseEntered, Final function. Handles mouse entered events.
      Specified by:
      mouseEntered in interface MouseListener
      Overrides:
      mouseEntered in class MouseAdapter
    • mouseExited

      public final void mouseExited(MouseEvent e)
      mouseExited, Final function. Handles mouse exited events.
      Specified by:
      mouseExited in interface MouseListener
      Overrides:
      mouseExited in class MouseAdapter
    • mouseClicked

      public final void mouseClicked(MouseEvent e)
      mouseClicked, Final function. Handles mouse clicked events.
      Specified by:
      mouseClicked in interface MouseListener
      Overrides:
      mouseClicked in class MouseAdapter
    • mouseWheelMoved

      public final void mouseWheelMoved(MouseWheelEvent e)
      mouseWheelMoved, Final function. Handles mouse wheel moved events.
      Specified by:
      mouseWheelMoved in interface MouseWheelListener
      Overrides:
      mouseWheelMoved in class MouseAdapter
    • mouseDragged

      public final void mouseDragged(MouseEvent e)
      mouseDragged, Final function. Handles mouse dragged events.
      Specified by:
      mouseDragged in interface MouseMotionListener
      Overrides:
      mouseDragged in class MouseAdapter
    • mouseMoved

      public final void mouseMoved(MouseEvent e)
      mouseMoved, Final function. Handles mouse moved events.
      Specified by:
      mouseMoved in interface MouseMotionListener
      Overrides:
      mouseMoved in class MouseAdapter