<AWT Dev> [9/8u40] Review request for RT-37149 and JDK-8049065 : Implement DnD for SwingNode
anthony.petrov at oracle.com
Fri Jul 18 14:44:09 UTC 2014
Hi Petr, Anton, Artem, Steve,
Please review the fix at https://javafx-jira.kenai.com/browse/RT-37149
JavaFX implements the DragSourceContextPeer and DragGestureRecognizer so
that SwingNode content could pose as a drag source. In order to support
a drop target, the DropTargetContextPeer is implemented in SwingNode and
the add/removeDropTarget() methods register/unregister the drop target
The changes in JDK are mostly technical. We simply delegate the
Toolkit.createDragGestureRecognizer() factory methods to SwingNode.
Similarly, we delegate the DropTargetPeer.add/removeDropTarget()
operations to SwingNode as well.
In FX I've factored out the CachingTransferable class from the
SwingDragSource class so as to share the implementation with the
SwingNode DnD support. Also I've added a few utility methods to
DataFlavorUtils and SwingFXUtils. The main fix is the new code in
FXDnD.java which actually implements the AWT interfaces, installs
appropriate event handlers on the SwingNode node in FX, and handles all
the DnD events.
Note that the JDK <-> FX interface is loose because I use default
methods in the LightweightContent interface, so that you can run new FX
with the old JDK, or old FX with the new JDK, and nothing should break.
Obviously, the DnD in SwingNode will only work if both JDK and FX are
I've tested these changes on Windows and Mac with the sample code from
this JIRA as well as a JFXPanel DnD test application from RT-34283. The
DnD works fine for me in both intra- and inter-process modes.
Please post your review comments in JIRA.
More information about the awt-dev