I have a basic, simple and maybe stupid question, but how do I implement that I can drag a file onto my java program and open it?
I searched really long for this basic question…..
As long as I found out you can’t implement dragging it onto the .jar, because its not executable. You have to create a .exe, which also open your .jar, but that’s all! I would really like to know how 🙂
A keyword would be enough, if I can get the answer through searching this keyword.
Thanks, Leander
//Edit: I may have expressed things a little bit complicated.
Later i want to have a shortcut on, for example, the desktop where i can drag any file on the shortcut and the programm opens with the file(it will, at this point) only move it to a special location.
I don´t know how the code for this would be, I even don’t know how to google for this (I only get questions how to implement “open with” with the answer Desktop.open(File f)).
The place to start reading is the JDK 6 documentation on Drag and Drop. Or else you can start directly with the Drag and Drop tutorials.
If you want to create a desktop icon that will open your app when you drop a file on it, this depends on the OS. I think that Launch4j will support this, although I haven’t used it in this way.