The objects in the list will be passed either as a String by calling the object's toString()
object, or if your drag and drop target accepts the TransferableObject.DATA_FLAVOR data flavor then the actual object will be passed.
I'm releasing this code into the Public Domain. Enjoy.
Original author: Robert Harder, rharder@usa.net
Public Member Functions | |
DnDList () | |
Constructs a default DnDList using a javax.swing.DefaultListModel. | |
DnDList (java.util.Vector data) | |
Constructs a DnDList by filling in a javax.swing.DefaultListModel with the passed java.util.Vector of objects. | |
DnDList (javax.swing.DefaultListModel model) | |
Constructs a DnDList using the passed list model that must be extended from javax.swing.DefaultListModel. | |
DnDList (Object[] data) | |
Constructs a DnDList by filling in a javax.swing.DefaultListModel with the passed array of objects. | |
void | dragDropEnd (java.awt.dnd.DragSourceDropEvent evt) |
void | dragEnter (java.awt.dnd.DragSourceDragEvent evt) |
void | dragEnter (java.awt.dnd.DropTargetDragEvent evt) |
void | dragExit (java.awt.dnd.DragSourceEvent evt) |
void | dragExit (java.awt.dnd.DropTargetEvent evt) |
void | dragGestureRecognized (java.awt.dnd.DragGestureEvent event) |
(non-Javadoc) | |
void | dragOver (java.awt.dnd.DragSourceDragEvent evt) |
void | dragOver (java.awt.dnd.DropTargetDragEvent evt) |
void | drop (java.awt.dnd.DropTargetDropEvent evt) |
void | dropActionChanged (java.awt.dnd.DragSourceDragEvent evt) |
void | dropActionChanged (java.awt.dnd.DropTargetDragEvent evt) |
Private Member Functions | |
void | initComponents () |
Private Attributes | |
java.awt.dnd.DragSource | dragSource = null |
int | sourceIndex = -1 |
Static Private Attributes | |
static final long | serialVersionUID = 4590546834426010393L |
Prevent serialization collisons. |
net.iharder.dnd.DnDList.DnDList | ( | ) |
net.iharder.dnd.DnDList.DnDList | ( | java.util.Vector | data | ) |
Constructs a DnDList by filling in a javax.swing.DefaultListModel with the passed java.util.Vector of objects.
data | The data from which to construct a list |
net.iharder.dnd.DnDList.DnDList | ( | javax.swing.DefaultListModel | model | ) |
Constructs a DnDList using the passed list model that must be extended from javax.swing.DefaultListModel.
model | The model to use |
net.iharder.dnd.DnDList.DnDList | ( | Object[] | data | ) |
Constructs a DnDList by filling in a javax.swing.DefaultListModel with the passed array of objects.
data | The data from which to construct a list |
void net.iharder.dnd.DnDList.dragGestureRecognized | ( | java.awt.dnd.DragGestureEvent | event | ) |
(non-Javadoc)
This will be called when the transfer data is requested at the very end. At this point we can remove the object from its original place in the list.
final long net.iharder.dnd.DnDList.serialVersionUID = 4590546834426010393L [static, private] |
Prevent serialization collisons.