public class ImageSelection extends java.lang.Object implements java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner
Transferable
which implements the capability required
to transfer an Image
. This Transferable
properly supports
DataFlavor.imageFlavor
and all equivalent flavors.
No other DataFlavors are supported.
Modified by: Joseph A. Huwaldt
Constructor and Description |
---|
ImageSelection(java.awt.Image image)
Creates a
Transferable capable of transferring the specified Image . |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor flavor)
Returns the
Transferable 's data in the requested DataFlavor if possible. |
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors()
Returns an array of flavors in which this
Transferable
can provide the data. |
boolean |
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns whether the requested flavor is supported by this
Transferable . |
void |
lostOwnership(java.awt.datatransfer.Clipboard clipboard,
java.awt.datatransfer.Transferable contents)
Notifies this object that it is no longer the clipboard owner.
|
public ImageSelection(java.awt.Image image)
Transferable
capable of transferring the specified Image
.public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Transferable
can provide the data. DataFlavor.imageFlavor
is properly supported.getTransferDataFlavors
in interface java.awt.datatransfer.Transferable
DataFlavor.imageFlavor
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Transferable
.isDataFlavorSupported
in interface java.awt.datatransfer.Transferable
flavor
- the requested flavor for the dataflavor
is equal to DataFlavor.imageFlavor
;
false if flavor
is any other flavor.public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
Transferable
's data in the requested DataFlavor
if possible.
If the desired flavor is DataFlavor.imageFlavor
, or an equivalent flavor, the
Image
representing the selection is returned.getTransferData
in interface java.awt.datatransfer.Transferable
flavor
- the requested flavor for the datajava.awt.datatransfer.UnsupportedFlavorException
- if the requested data flavor is not equivalent to DataFlavor.imageFlavorjava.io.IOException
- if the data is no longer available in the requested flavor.java.lang.NullPointerException
- if flavor is null
public void lostOwnership(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable contents)
lostOwnership
in interface java.awt.datatransfer.ClipboardOwner