views:

127

answers:

3

I want to create an application in Java that lists a directory and add drag and drop support to it for copying files from that directory to the explorer window opened and vice-versa(Windows system).

While adding support to drag and drop from windows explorer to the java application is quite easy, it kind of eludes me how to do it when the action starts from the java application and ends in explorer.

I tried searching google and SO, but to no avail.

Any pointers, directions, snippets of codes or pseudocodes will be appreciated.

So, is it possible to drag from a java application and transfer data to a drop target in a native application? If yes (it should be), can you point me in the right direction?

+1  A: 

Yes, what you have to do is set the mime type on the transferable, and set the accepted actions (i.e. copy, move, etc) as well as the default action (it sounds like a copy action for what you are trying to do). This class is the transfer handler, which is what is used to handle DnD in Swing.

aperkins
+1  A: 

Just use the fileListFlavour DataFlavour and File drag'n drop will "just work" in both directions.

I'm sure you found the section on drag n drop in the java tutorial.

zedoo
A: 

Book: Swing Hacks Hack # 65 That's your answer :)

Chaitanya