This discussion is archived
7 Replies Latest reply: Mar 9, 2012 2:54 AM by 875776 RSS

How to implement drag from Java Desktop Application & drop to Native File?

875776 Newbie
Currently Being Moderated
I am currently using JAVA 6 and my Java desktop application shows a list of the files from server. I would like to have a download selected files to native file system using Drag and Drop. I have gone through many links but almost every link describes the Drag and Drop with-in a Java swing applications. I have not found help to implement download using drag from Java desktop Application & drop to Native File.

For example, let's suppose, I have dragged the file from my java swing application and dropped directly to the desktop then download should take place and I should know where the file is being downloaded. The files that are being downloaded may be in GBs and take several hours to download. I need destination location because if the download fails then I can re-try download.

Please consider following steps to clarify what I have explained, how it will work and what is my requirement -

1. User runs application.
2. The list of files from server displays in JTable.
3. Now user restores down the application window.
4. User selects some files from JTable.
5. Drags out of the application onto his computer to download.
6. Downloading supposed to be started from server to the location where he drops that file on his computer.


Any help will be greatly appreciated.
  • 1. Re: How to implement drag from Java Desktop Application & drop to Native File?
    gimbal2 Guru
    Currently Being Moderated
    872773 wrote:
    I am currently using JAVA 6 and my Java Desktop application shows a list of the files from server. I would like to have a download selected files to native file system using Drag and Drop. I have gone through many links but almost every link describes the Drag and Drop with-in a Java swing applications. I have not found help to implement download using drag from Java Desktop Application & drop to Native File.
    Huh? Swing is an API to create GUIs for client applications. Or as you call it: desktop applications :s

    I think you have your terminology mixed up. What type of application are you really talking about? A web application perhaps, since you mention a server?
  • 2. Re: How to implement drag from Java Desktop Application & drop to Native File?
    875776 Newbie
    Currently Being Moderated
    It's not a web application. It's a Java desktop application using Swing. It runs on Windows, Mac OS X, Linux , and any other major desktop platform with a Java run-time. User installs and runs application on native file system and it shows a list of the files that have been uploaded to the server. User can download files from server. Now I would like to support download feature using Drag and Drop.
  • 3. Re: How to implement drag from Java Desktop Application & drop to Native File?
    EJP Guru
    Currently Being Moderated
    A drag recipient that has specific download semantics has to be written to implement those semantics.

    Whether in Java or some other language is a secondary question.
  • 4. Re: How to implement drag from Java Desktop Application & drop to Native File?
    gimbal2 Guru
    Currently Being Moderated
    Argh, I completely missed the point of the drag & drop being -the other way around-. From the application to the filesystem...
  • 5. Re: How to implement drag from Java Desktop Application & drop to Native File?
    875776 Newbie
    Currently Being Moderated
    Thanks. Please consider following steps to clarify what I have explained, how it will work and what is my requirement -

    1. User runs application.
    2. The list of files from server displays in JTable.
    3. Now user restores down the application window.
    4. User selects some files from JTable.
    5. Drags out of the application onto his computer to download.
    6. Downloading supposed to be started from server to the location where he drops that file on his computer.

    Please let me know if you need more details.
  • 6. Re: How to implement drag from Java Desktop Application & drop to Native File?
    gimbal2 Guru
    Currently Being Moderated
    Yes it is clear now what you want to do. Unfortunately I know of no way to be able to do that. When you drag files to a Java application, you are within your realm of control (the Java application itself). You deal with the drop logic in the target, as in the component that is receiving the drop. That makes sense as depending on where you drop files you will deal with it differently. Dropping an image on a JTable may add a entry to the JTable, dropping an image on a JPanel might trigger the image to be rendered for example.

    In the case you pose, the target is completely outside of your application. In fact it can be basically any other application, including the shell of the OS.

    The best that I can think of is that you reserve a special area inside your own application to which you can drag and drop the files, which will cause your application to put the files in the proper spot on the filesystem. Think of it like adding a trashcan icon to which you can drag and drop stuff to remove it, only differently.
  • 7. Re: How to implement drag from Java Desktop Application & drop to Native File?
    875776 Newbie
    Currently Being Moderated
    Thanks for your suggestion. I wonder there is no way to implement such drag and drop support. There are some older discussion exist for such type of implementation but they are not updated since 2010.

    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4808793
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4816922

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points