com.partnersoft.gui
Class Dragabout<T>

java.lang.Object
  extended by com.partnersoft.gui.Dragabout<T>
Type Parameters:
T - payload type

public abstract class Dragabout<T>
extends java.lang.Object

A simpler alternative to Java drag-and-drop.

Java drag-and-drop is really a data transfer mechanism, has hooks into the clipboard, allows dragging between applications, etc. It's a complicated mess with several versions (AWT, Swing, etc.). This is a simpler alternative, designed to manage dragging behavior within the same application only.

Copyright 2007 Partner Software, Inc.

Version:
$Id: Dragabout.java 2046 2009-08-25 05:28:53Z paul $
Author:
Paul Reavis

Constructor Summary
Dragabout()
           
 
Method Summary
 void addSink(java.awt.Component newSink)
           
 void addSource(java.awt.Component newSource)
           
abstract  void drag(java.awt.Component component, T payload, int pixelX, int pixelY)
          Called during the drag.
abstract  void drop(java.awt.Component source, java.awt.Component sink, T payload, int pixelX, int pixelY)
          Called at the end of the drag (the drop).
abstract  T grab(java.awt.Component source, int pixelX, int pixelY)
          Called at the beginning of a drag.
 void removeSink(java.awt.Component sink)
           
 void removeSource(java.awt.Component source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dragabout

public Dragabout()
Method Detail

addSource

public void addSource(java.awt.Component newSource)

removeSource

public void removeSource(java.awt.Component source)

addSink

public void addSink(java.awt.Component newSink)

removeSink

public void removeSink(java.awt.Component sink)

grab

public abstract T grab(java.awt.Component source,
                       int pixelX,
                       int pixelY)
Called at the beginning of a drag. You must supply the object that will be dragged from one place to another. Return null if there is nothing to drag (therefore no drag occurs).


drag

public abstract void drag(java.awt.Component component,
                          T payload,
                          int pixelX,
                          int pixelY)
Called during the drag. You should supply any visuals desired based on the given drag parameters.


drop

public abstract void drop(java.awt.Component source,
                          java.awt.Component sink,
                          T payload,
                          int pixelX,
                          int pixelY)
Called at the end of the drag (the drop). If the drop occurred over one or more registered sink components, then the component argument will be that component and the pixel coordinates will be relative to that component's origin.