|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ojb.tools.mapping.reversedb2.dnd2.DropTargetHelper
Starting from JDK 1.2 drag and drop was possible for Java applications. Unfortunately
the framework to be used is rather complex. As of JDK 1.4 a new, more simple Dnd framework
was added, but unfortunately if you want to be backwards compatible, you still have to
stick with the old framework.
This helper class should make it easier to implement DnD for JDK 1.2 and 1.3. To add drop
support for a Component, you only have to write your Implementation of DropPasteWorkerInterface.
This interface is responsible to read data from a Transferable and add it to the model of the
target component.
DropTargetHelper helper = new DropTargetHelper();
helper.registerDropPasteWorker (new ReverseDbNodesDropWorker());
aComponent.setDropTarget(helper.getDropTarget ());
If you want to supply your own implementation of a DropTargetListener or an extension
of the implementation in this class, you have to use the following code:
helper.setDefaultDropTargetListener(aDTListener);
helper.removeDefaultDropTargetListener();
helper.registerDefaultDropTargetListener();
Because the DropTarget is a unicast source, you first have to remove the
old listener and the register the new. If you do not remove the listener
before adding a new one, a TooManyListenersException is thrown.
Nested Class Summary | |
class |
DropTargetHelper.DTListener
An implementation of a DropTargetListener. |
Constructor Summary | |
DropTargetHelper()
Creates a new instance of DropTarget |
Method Summary | |
java.awt.dnd.DropTarget |
getDropTarget()
Get the DropTarget (to be used in Component.setDropTarget()); |
void |
registerDefaultDropTargetListener()
Set the current DropTargetListener as listener of the current DropTarget. |
void |
registerDropPasteWorker(DropPasteWorkerInterface worker)
Register a new DropPasteWorkerInterface. |
void |
removeDefaultDropTargetListener()
Remove current DropTargetListener from the DropTarget. |
void |
removeDropPasteWorker(DropPasteWorkerInterface worker)
Remove a DropPasteWorker from the helper. |
void |
setDefaultDropTargetListener(java.awt.dnd.DropTargetListener dtl)
Set a new DropTargetListner this helper is going to use. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DropTargetHelper()
Method Detail |
public void removeDefaultDropTargetListener()
public void registerDefaultDropTargetListener() throws java.util.TooManyListenersException
TooManyListenersException
public void setDefaultDropTargetListener(java.awt.dnd.DropTargetListener dtl)
dtl
- The new DropTargetListenerpublic void registerDropPasteWorker(DropPasteWorkerInterface worker)
worker
- The new workerpublic void removeDropPasteWorker(DropPasteWorkerInterface worker)
worker
- the worker that should be removedpublic java.awt.dnd.DropTarget getDropTarget()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |