
Handling Dropped Picts on Mac OS X #68
Chapter 9, Drag-and-Drop
|
345
HACK
When dropped, you’ll see the image appear in its own JFrame. In Figure 9-5,
I’ve dragged small images from several different applications, resulting in
each being opened in its own frame.
This won’t work if you’re dragging an image from one of the Mac OS X
applications that only supplies one
DataFlavor. You’ll have to deal with Picts
[Hack #68] in that situation.
H A C K
#68
Handling Dropped Picts on Mac OS X Hack #68
For Mac applications that provide only the legacy Pict flavor of drops,
QuickTime for Java offers a Mac-specific solution.
You should already recognize the existence of hard-to-handle DataFlavors
[Hack #67] passed by certain Mac applications. Of the Mac apps I tested, sev-
eral old apps (many using the Carbon APIs, which were developed to migrate
classic Mac apps to OS X) support only one
DataFlavor. When I drop from
GraphicConverter, QuickTime Player, AppleWorks, and MarinerWrite, the
only supported
DataFlavor was reported as:
java.awt.datatransfer.DataFlavor[mimetype=image/x-pict;
representationclass=java.io.InputStream]
Figure 9-4. Dragging an image from a native application to a Swing component
Figure 9-5. Image dropped from a native application and opened in Swing