Copying Images to a Clipboard

As we have seen, manipulating clipboards is relatively straightforward. Perhaps the most difficult aspect of the clipboard/data transfer mechanism is copying data other than text to a clipboard, and even that is not rocket science, especially once you get you've gotten the hang of it.

ImageSelection—A Transferable for Encapsulating Images

The first order of business is to develop a class that implements Transferable and encapsulates an image. Our first version of such a class will offer a lone data flavor for representing the image—java.awt.Image. A little later on, we'll add another data flavor for good measure.

We'll follow the naming convention established by StringSelection and name our class ImageSelection

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.