I solved the problem of exporting files via drag and drop by making
getTransferData
return a java.util.List containing java.io.File objects. By creating
a temporary file with
the appropriate name as a java.io.File, I was able to specify the
name of the object
created on the desktop and read it with other applications.
I have not been able to return java.net.URL objects from
getTransferData. In fact,
getTransferData never even gets invoked for objects which I advertise
as returning
java.net.URL, so I assume Apple and/or Sun do not support
java.net.URL here.
Examining some .webloc files with DeRez reveals that they are similar
to text
clippings, i.e. the interesting stuff is in the resource fork. So it
seems to me that the
way to export URLs via drag and drop might be to create a
java.io.File, provide it
with the necessary resource fork and export that from getTransferData.
Is this possible in Java? The only stuff I've been able to find in
Google seems to
be able to read resource forks but not write them.
Steve
On 23 Sep 2005, at 17:34, Stephen Winnall wrote:
I have a Java application which uses drag and drop. I have managed
to export
some objects to the Mac OS X desktop by setting up a DataFlavor
which uses the
representation class java.io.InputStream and making getTransferData
do the
work as per http://java.sun.com/docs/books/tutorial/uiswing/misc/
dnd.html.
The objects created on the Mac OS X desktop have the file extension
".textClipping"
and Get Info tells me they have the kind "Text Clipping". They seem
to contain what
I put into them.
However, I have some issues which I hope someone may be able to
help me with:
1) the text clippings do not appear to be "proper" files (I suppose
their name supports
this notion). I can't access them with other applications.
2) I don't know how to assign names to the text clippings (perhaps
this is because
I am not creating "proper" files).
3) I haven't managed to create anything on the Mac OS X desktop
when I pass out
a java.net.URL. Is it possible, or is the java.io.InputStream route
the only possible
way?
"Swing Hacks" shows an alternative (lower level?) technique for
dragging and dropping
based on DragSourceAdapter and DragGestureListener. Obviously I
could use that,
but I have a lot of other drag-and-drop code based on the style in
the Sun tutorial
which I am loathe to discard or redo.
Can anyone give me hints on how to solve problems 1, 2 and 3?
Ultimately, my application has to run on Mac OS X, Windows and
Linux, but I'd be
happy initially if I had a solution for Mac OS X.
Regards
Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40vimia.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden