Java Reference
In-Depth Information
AWTsupportstransferringarbitraryobjectsbetweenapplicationsviathe system clip-
board ,andtransferringobjectswithinanapplicationviaa private clipboard .Thissup-
portconsistsofthe java.awt.datatransfer packagewithits ClipboardOwn-
er , FlavorListener , FlavorMap , FlavorTable , and Transferable in-
terfaces; and Clipboard , DataFlavor , FlavorEvent , StringSelection ,
SystemFlavorMap , MimeTypeParseException , and UnsupportedFla-
vorException classes.
Clipboard provides a mechanism for transferring data to a clipboard by using
cut/copy/paste operations. You can obtain a singleton (single instance) Clipboard
object that provides access to the native clipboard facilities offered by the platform's
windowingsystembycalling Toolkit 's Clipboard getSystemClipboard()
method; for example, Clipboard clipboard =
Toolkit.getDefaultToolkit.getSystemClipboard(); . Alternatively,
you can obtain a private clipboard by instantiating Clipboard .
Clipboard declares a void setContents(Transferable contents,
ClipboardOwner owner) methodthatsetsthecurrentcontentsoftheclipboardto
ofthenewcontents.Thismethodthrows java.lang.IllegalStateException
when the clipboard is currently unavailable.
Thetransferableobjectthat'spassedto contents iscreatedfromaclassthatimple-
ments the Transferable interface in terms of the following three methods:
Object getTransferData(DataFlavor flavor) returnsanobject
containing the data being transferred. The DataFlavor argument identifies
the flavor (format)ofthisdata(e.g.,astringoraJPEGimage)byencapsulating
the data's Multipurpose Internet Mail Extensions (MIME) type— ht-
tp:// and ht-
tp:// discuss
odthrows whenthedataisnolongeravailablein
the requested flavor, and UnsupportedFlavorException when the re-
quested data flavor isn't supported.
DataFlavor[] getTransferDataFlavors() returns an array of
DataFlavor objectsthatindicatetheflavorsofthedatathatthistransferable
object can provide.
Search WWH ::

Custom Search