So, in How can I use Drag-and-Drop in Swing to get file path?, several different solutions are suggested: one pointing to the TransferHandler
tutorial (which doesn't actually explain how to drag and drop files, only explaining dragging JComponents, and then giving a demo with multiple moving parts and no explanation for files), one using DropTarget
and DropTargetDropEvent
, and one using an external library called FileDrop
. The fourth answer (thankfully) actually explained what TransferHandler
is and how to implement it for files, but the question I have is:
Which of these methods is best to use?
I don't know about using the external library if there is native support, but the big thing I don't understand is DropTarget
.
I've only previously seen DropTarget
used in programs written in Java 7 and earlier, so I assumed that it was made obsolete by TransferHandler
, but the solution in the linked question says that it should be used for Java 7 or later. I'm very confused.
Thank you for your time, and I look forward to a response!