I'm implementing drag-and-drop and copy/paste file export in a Java application that needs to run on Mac OS, Windows, and Linux. I've got a Transferable implementation that handles DataFlavor.javaFileListFlavor
and I've managed to get drag-and-drop working well so far.
But I'm stuck on copy/paste export. While hunting around I found an answer that I thought might help: https://stackoverflow.com/a/31798747
Indeed, this works on Windows, but not on Mac OS, where I develop, and I think that's the problem, but I'm having a hard time wrapping my head around it.
I also found an old unanswered question from someone who I think was struggling with the same problem, but I think their conclusion that Mac OS Finder doesn't handle DataFlavor.javaFileListFlavor
isn't quite right: What is the required DataFlavor to copy files in Mac OSX
- I can drag-and-drop into the Mac OS Finder, desktop, or other applications that accept drop events from files. So clearly Mac OS can handle
javaFileListFlavor
. - I can also import from the system clipboard by copy-pasting out of Finder into my application (by handling
javaFileListFlavor
), so clearly the clipboard provides something that Java can interpret asjavaFileListFlavor
. - I set a breakpoint and looked at
ClipboardTransferable.getTransferDataFlavors()
andjavaFileListFlavor
is there, along with a whole bunch of other flavors, but I'm not sure how to proceed.
I suspect I need to provide handling for a different flavor to allow the clipboard to handle files from Java. But I don't have any idea what that flavor would be, or how to go about figuring this out.