Class SwingDragger

  • All Implemented Interfaces:
    java.awt.dnd.DragSourceListener, java.awt.dnd.DragSourceMotionListener, java.util.EventListener

    public class SwingDragger
    extends java.lang.Object
    implements java.awt.dnd.DragSourceListener, java.awt.dnd.DragSourceMotionListener
    A class to manage dragging.
    • Constructor Summary

      Constructors 
      Constructor Description
      SwingDragger()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void createDragWindow()
      Creates new drag source listener.
      protected java.awt.datatransfer.Transferable createTransferable()
      Creates a transferable for DragItem.
      static java.awt.datatransfer.Transferable createTransferable​(java.lang.Object anItem)
      Creates a transferable for given object.
      void dragDropEnd​(java.awt.dnd.DragSourceDropEvent anEvent)
      DragSourceListener method.
      void dragEnter​(java.awt.dnd.DragSourceDragEvent anEvent)
      DragSourceListener method.
      void dragExit​(java.awt.dnd.DragSourceEvent anEvent)
      DragSourceListener method.
      void dragMouseMoved​(java.awt.dnd.DragSourceDragEvent anEvent)
      DragSourceMotionListener method.
      void dragOver​(java.awt.dnd.DragSourceDragEvent anEvent)
      DragSourceListener method.
      void dropActionChanged​(java.awt.dnd.DragSourceDragEvent anEvent)
      DragSourceListener method.
      static SwingDragger getActiveDragger()
      Returns the currently active dragger.
      protected javax.swing.JComponent getComponent()
      Returns the component.
      java.awt.dnd.DragGestureEvent getDragGestureEvent()
      Returns the DragGestureEvent.
      java.awt.Image getDragImage()
      Returns the image to be dragged.
      protected java.awt.Point getDragImageOffset()
      Returns the drag image offset point.
      java.awt.Point getDragImagePoint()
      Returns the point that the drag image should be dragged by.
      java.lang.Object getDragItem()
      Returns the item really being dragged.
      <T> T getDragItem​(java.lang.Class<T> aClass)
      Returns the drag item as given class.
      java.lang.String getDragItemString()
      Returns the drag item as string.
      java.awt.dnd.DragSource getDragSource()
      Returns the DragSource.
      java.awt.dnd.DragSourceListener getDragSourceListener()
      Returns the optional DragSourceListener.
      java.awt.datatransfer.Transferable getTransferable()
      Sets the transferable.
      void setDragGestureEvent​(java.awt.dnd.DragGestureEvent anEvent)
      Sets the DragGestureEvent.
      void setDragImage​(java.awt.Image anImage)
      Sets the image to be dragged.
      void setDragImageFromString​(java.lang.String aString, java.awt.Font aFont)
      Sets the drag image from given string and font.
      void setDragImagePoint​(double anX, double aY)
      Returns the point that the drag image should be dragged by.
      void setDragImagePoint​(java.awt.Point aPoint)
      Returns the point that the drag image should be dragged by.
      void setDragItem​(java.lang.Object anItem)
      Sets the item really being dragged.
      void setDragSourceListener​(java.awt.dnd.DragSourceListener aListener)
      Sets an optional DragSourceListener.
      void setTransferable​(java.awt.datatransfer.Transferable aTrans)
      Sets the transferable.
      void setTransferable​(java.lang.String aString)
      Sets the transferable from string.
      void startDrag()
      Starts the drag.
      • Methods inherited from class java.lang.Object

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

      • SwingDragger

        public SwingDragger()
    • Method Detail

      • getDragItem

        public java.lang.Object getDragItem()
        Returns the item really being dragged.
      • setDragItem

        public void setDragItem​(java.lang.Object anItem)
        Sets the item really being dragged.
      • getDragItem

        public <T> T getDragItem​(java.lang.Class<T> aClass)
        Returns the drag item as given class.
      • getDragItemString

        public java.lang.String getDragItemString()
        Returns the drag item as string.
      • getDragGestureEvent

        public java.awt.dnd.DragGestureEvent getDragGestureEvent()
        Returns the DragGestureEvent.
      • setDragGestureEvent

        public void setDragGestureEvent​(java.awt.dnd.DragGestureEvent anEvent)
        Sets the DragGestureEvent.
      • getDragImage

        public java.awt.Image getDragImage()
        Returns the image to be dragged.
      • setDragImage

        public void setDragImage​(java.awt.Image anImage)
        Sets the image to be dragged.
      • setDragImageFromString

        public void setDragImageFromString​(java.lang.String aString,
                                           java.awt.Font aFont)
        Sets the drag image from given string and font.
      • getDragImagePoint

        public java.awt.Point getDragImagePoint()
        Returns the point that the drag image should be dragged by.
      • setDragImagePoint

        public void setDragImagePoint​(java.awt.Point aPoint)
        Returns the point that the drag image should be dragged by.
      • setDragImagePoint

        public void setDragImagePoint​(double anX,
                                      double aY)
        Returns the point that the drag image should be dragged by.
      • getDragImageOffset

        protected java.awt.Point getDragImageOffset()
        Returns the drag image offset point.
      • getTransferable

        public java.awt.datatransfer.Transferable getTransferable()
        Sets the transferable.
      • setTransferable

        public void setTransferable​(java.awt.datatransfer.Transferable aTrans)
        Sets the transferable.
      • setTransferable

        public void setTransferable​(java.lang.String aString)
        Sets the transferable from string.
      • createTransferable

        protected java.awt.datatransfer.Transferable createTransferable()
        Creates a transferable for DragItem.
      • createTransferable

        public static java.awt.datatransfer.Transferable createTransferable​(java.lang.Object anItem)
        Creates a transferable for given object.
      • getDragSourceListener

        public java.awt.dnd.DragSourceListener getDragSourceListener()
        Returns the optional DragSourceListener.
      • setDragSourceListener

        public void setDragSourceListener​(java.awt.dnd.DragSourceListener aListener)
        Sets an optional DragSourceListener.
      • getComponent

        protected javax.swing.JComponent getComponent()
        Returns the component.
      • getDragSource

        public java.awt.dnd.DragSource getDragSource()
        Returns the DragSource.
      • startDrag

        public void startDrag()
        Starts the drag.
      • getActiveDragger

        public static SwingDragger getActiveDragger()
        Returns the currently active dragger.
      • createDragWindow

        protected void createDragWindow()
        Creates new drag source listener.
      • dragEnter

        public void dragEnter​(java.awt.dnd.DragSourceDragEvent anEvent)
        DragSourceListener method.
        Specified by:
        dragEnter in interface java.awt.dnd.DragSourceListener
      • dragMouseMoved

        public void dragMouseMoved​(java.awt.dnd.DragSourceDragEvent anEvent)
        DragSourceMotionListener method.
        Specified by:
        dragMouseMoved in interface java.awt.dnd.DragSourceMotionListener
      • dragDropEnd

        public void dragDropEnd​(java.awt.dnd.DragSourceDropEvent anEvent)
        DragSourceListener method.
        Specified by:
        dragDropEnd in interface java.awt.dnd.DragSourceListener
      • dragOver

        public void dragOver​(java.awt.dnd.DragSourceDragEvent anEvent)
        DragSourceListener method.
        Specified by:
        dragOver in interface java.awt.dnd.DragSourceListener
      • dragExit

        public void dragExit​(java.awt.dnd.DragSourceEvent anEvent)
        DragSourceListener method.
        Specified by:
        dragExit in interface java.awt.dnd.DragSourceListener
      • dropActionChanged

        public void dropActionChanged​(java.awt.dnd.DragSourceDragEvent anEvent)
        DragSourceListener method.
        Specified by:
        dropActionChanged in interface java.awt.dnd.DragSourceListener