public class DragTextField
extends JTextField implements DragGestureListener, DragSourceListener
{
private DragSource dragSource;
/**************************************************************************
*
*
*************************************************************************/
public DragTextField()
{
dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_COPY_OR_MOVE, this);
}
/**************************************************************************
*
* @param dge DragGestureEvent
*************************************************************************/
public void dragGestureRecognized(DragGestureEvent dge)
{
Transferable t = new StringSelection("");
dragSource.startDrag(dge, DragSource.DefaultCopyDrop, t, this);
}
/**************************************************************************
*
* @param dsde DragSourceDragEvent
*************************************************************************/
public void dragEnter(DragSourceDragEvent dsde)
{
}
/**************************************************************************
*
* @param dsde DragSourceDragEvent
*************************************************************************/
public void dragOver(DragSourceDragEvent dsde)
{
}
/**************************************************************************
*
* @param dsde DragSourceDragEvent
*************************************************************************/
public void dropActionChanged(DragSourceDragEvent dsde)
{
}
/**************************************************************************
*
* @param dsde DragSourceDropEvent
*************************************************************************/
public void dragDropEnd(DragSourceDropEvent dsde)
{
//hier kommst du rein, wenn du dann dein Element auslässt!
//und hier machst du ein remove(this) (also vom panel wegnehmen) und wieder neu draufadden und schon isses dort
}
}