+ /**
+ * The image selection class.
+ */
+ private ImageSelection imageSelection;
+
+ /**
+ * ImageSelection is used to hold an image while on the clipboard.
+ */
+ private class ImageSelection implements Transferable {
+
+ /**
+ * Returns an array of DataFlavor objects indicating the flavors the
+ * data can be provided in. The array should be ordered according to
+ * preference for providing the data (from most richly descriptive to
+ * least descriptive).
+ *
+ * @return an array of data flavors in which this data can be
+ * transferred
+ */
+ public DataFlavor[] getTransferDataFlavors() {
+ return new DataFlavor[] { DataFlavor.imageFlavor };
+ }
+
+ /**
+ * Returns whether or not the specified data flavor is supported for
+ * this object.
+ *
+ * @param flavor the requested flavor for the data
+ * @return boolean indicating whether or not the data flavor is
+ * supported
+ */
+ public boolean isDataFlavorSupported(DataFlavor flavor) {
+ return DataFlavor.imageFlavor.equals(flavor);
+ }
+
+ /**
+ * Returns an object which represents the data to be transferred. The
+ * class of the object returned is defined by the representation
+ * class of the flavor.
+ *
+ * @param flavor the requested flavor for the data
+ * @throws IOException if the data is no longer available in the
+ * requested flavor.
+ * @throws UnsupportedFlavorException if the requested data flavor is
+ * not supported.
+ */
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException {
+
+ if (!DataFlavor.imageFlavor.equals(flavor)) {
+ throw new UnsupportedFlavorException(flavor);
+ }
+ return image;
+ }
+ }
+