Class MouseLiberalAdapter

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

    public abstract class MouseLiberalAdapter
    extends java.awt.event.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."); } });
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void mouseClick​(java.awt.event.MouseEvent e)
      mouseClick, Override this function to catch standard mouse click events.
      void mouseClicked​(java.awt.event.MouseEvent e)
      mouseClicked, Final function.
      void mouseDrag​(java.awt.event.MouseEvent e)
      mouseDrag, Override this function to catch standard mouse drag events.
      void mouseDragged​(java.awt.event.MouseEvent e)
      mouseDragged, Final function.
      void mouseEnter​(java.awt.event.MouseEvent e)
      mouseEnter, Override this function to catch standard mouse enter events.
      void mouseEntered​(java.awt.event.MouseEvent e)
      mouseEntered, Final function.
      void mouseExit​(java.awt.event.MouseEvent e)
      mouseExit, Override this function to catch standard mouse exit events.
      void mouseExited​(java.awt.event.MouseEvent e)
      mouseExited, Final function.
      void mouseLiberalClick​(java.awt.event.MouseEvent e)
      mouseLiberalClick, Override this function to catch liberal single click events.
      void mouseLiberalDoubleClick​(java.awt.event.MouseEvent e)
      mouseLiberalDoubleClick, Override this function to catch liberal double click events.
      void mouseMove​(java.awt.event.MouseEvent e)
      mouseMove, Override this function to catch standard mouse move events.
      void mouseMoved​(java.awt.event.MouseEvent e)
      mouseMoved, Final function.
      void mousePress​(java.awt.event.MouseEvent e)
      mousePress, Override this function to catch standard mouse press events.
      void mousePressed​(java.awt.event.MouseEvent e)
      mousePressed, Final function.
      void mouseRelease​(java.awt.event.MouseEvent e)
      mouseRelease, Override this function to catch standard mouse release events.
      void mouseReleased​(java.awt.event.MouseEvent e)
      mouseReleased, Final function.
      void mouseWheelMove​(java.awt.event.MouseWheelEvent e)
      mouseWheelMove, Override this function to catch standard mouse wheel move events.
      void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
      mouseWheelMoved, Final function.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MouseLiberalAdapter

        public MouseLiberalAdapter()
    • Method Detail

      • mouseLiberalClick

        public void mouseLiberalClick​(java.awt.event.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​(java.awt.event.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​(java.awt.event.MouseEvent e)
        mouseClick, Override this function to catch standard mouse click events.
      • mousePress

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

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

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

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

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

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

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

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

        public final void mouseReleased​(java.awt.event.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 java.awt.event.MouseListener
        Overrides:
        mouseReleased in class java.awt.event.MouseAdapter
      • mouseEntered

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

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

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

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

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

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