Class DragListener

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

    public class DragListener
    extends java.awt.event.MouseAdapter
    implements java.awt.event.MouseMotionListener
    This listener can be used to make a Component draggable. If subscribed as MouseListener and MouseMotionListener, the component this listener subscribes to will become draggable by mouse. This subscription is done by the static method #makeDraggable(Component) to make sure it is done the right way.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Component component  
      private java.awt.Point lastMousePos  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DragListener​(java.awt.Component component)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void makeDraggable​(java.awt.Component component)  
      void mouseDragged​(java.awt.event.MouseEvent e)  
      void mouseMoved​(java.awt.event.MouseEvent e)  
      void mouseReleased​(java.awt.event.MouseEvent e)  
      • Methods inherited from class java.awt.event.MouseAdapter

        mouseClicked, mouseEntered, mouseExited, mousePressed, mouseWheelMoved
      • Methods inherited from class java.lang.Object

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

      • component

        private final java.awt.Component component
      • lastMousePos

        private java.awt.Point lastMousePos
    • Constructor Detail

      • DragListener

        private DragListener​(java.awt.Component component)
    • Method Detail

      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseDragged in class java.awt.event.MouseAdapter
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseMoved in class java.awt.event.MouseAdapter
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Overrides:
        mouseReleased in class java.awt.event.MouseAdapter
      • makeDraggable

        public static void makeDraggable​(java.awt.Component component)