edu.northwestern.at.utils.swing
Class ListDragSource

java.lang.Object
  extended by edu.northwestern.at.utils.swing.XDragSource
      extended by edu.northwestern.at.utils.swing.ListDragSource
All Implemented Interfaces:
java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.util.EventListener

public abstract class ListDragSource
extends XDragSource

An abstract base class for JList drag source components.

Dragging multiple element selections is supported. This class takes care of building the drag image. The concrete subclass takes care of building the drag data via the getTransferable method which it must implement.


Constructor Summary
ListDragSource(javax.swing.JList list)
          Constructs a new list drag source.
 
Method Summary
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
          Handles drag gesture recognized events.
abstract  java.awt.datatransfer.Transferable getTransferable()
          Gets the drag data.
 
Methods inherited from class edu.northwestern.at.utils.swing.XDragSource
dragDropEnd, dragEnter, dragExit, dragOver, dropActionChanged, getCurrentDragData, getCurrentDragSource, getTriggerEvent, startDrag, startDrag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListDragSource

public ListDragSource(javax.swing.JList list)
Constructs a new list drag source.

Parameters:
list - The list.
Method Detail

dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
Handles drag gesture recognized events.

If the drag originated in a non-selected element, that element is selected. Otherwise the selection is unchanged.

Builds a drag image for all the selected list elements, asks the subclass to build the drag data, then invokes XDragSource.startDrag to start the drag.

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener
Specified by:
dragGestureRecognized in class XDragSource
Parameters:
dge - The event.

getTransferable

public abstract java.awt.datatransfer.Transferable getTransferable()
Gets the drag data.

Returns:
The drag data.