ivb
ivb

Reputation: 167

DragNDrop from Java to Windows Explorer

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?

Upvotes: 2

Views: 902

Answers (3)

Chaitanya
Chaitanya

Reputation: 2049

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

Upvotes: 0

zedoo
zedoo

Reputation: 11287

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.

Upvotes: 1

aperkins
aperkins

Reputation: 13124

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.

Upvotes: 1

Related Questions