ct*****@yahoo.com.au (cte) wrote in message news:<c1**************************@posting.google. com>...
I have a swing program involving drag and drop - implemented with
javax.swing.TransferHandler etc.
My problem is that I want to determine the mouse coordinates of a drop
onto one of my components and TransferHandler does not seem to have
any means of doing this.
I don't know if it's bad form to reply to my own post but I've worked
out a semi-solution that does enough. There's a method in
java.awt.Component (which is an ancestor of JComponent): public
DropTarget getDropTarget (). I was able to call this method which
retrieves the Swing implementation (an inner class of
TransferHandler), and add a java.awt.dnd.DropTargetListener to it.
Now for the dodgy bit ;D. The documentation for DropTarget indicates
that only one DropTargetListener may be attached to a DropTarget and
an Exception is thrown if you try to add more than one. However the
inner class of TransferHandler that is a DropTarget does *not* throw
an Exception. Lucky for me, but I'm also uncomfortable relying on a
private implementation detail like this...
Cheers
Chris