0

I am trying to create a program were the user drags a file into an area (currently a JTextArea, but can be another container) and it adds the absolute path of the file to an ArrayList. I am having trouble figuring out how to implement drag and drop of files.

so far I have tried reading some similar questions but they aren't really helping me. (also this is targeting windows but linux/mac support is an option as well)

Maroun
  • 94,125
  • 30
  • 188
  • 241
  • So, you're using Swing? – mre Apr 08 '13 at 19:42
  • 1
    And possible duplicate - http://stackoverflow.com/questions/811248/how-can-i-use-drag-and-drop-in-swing-to-get-file-path – mre Apr 08 '13 at 19:43
  • "asked May 1 '09 at 13:00" to the above and i did not see that one in my searches, ill read into it –  Apr 09 '13 at 02:36

2 Answers2

0

Here is a full blown example.

Nándor Krácser
  • 1,128
  • 8
  • 13
0

Have a look at oracles page about DnD. Basically you can drag everything into your program, should it be a file directly from a native browser or the JFileChooser. What you are dragging is only the path to the file. So you only have to set your JTextAreato accept drops and define how it has to "interpret" the object that was being dropped.

GameDroids
  • 5,584
  • 6
  • 40
  • 59
  • already looked at the dnd section but didn't see anything about files, must have overlooked it. –  Apr 09 '13 at 02:34