java.lang.Object
java.awt.datatransfer.StringSelection
- All Implemented Interfaces:
- ClipboardOwner,- Transferable
A 
Transferable which implements the capability required to transfer a
 String.
 
 This Transferable properly supports DataFlavor.stringFlavor
 and all equivalent flavors. Support for DataFlavor.plainTextFlavor
 and all equivalent flavors is deprecated. No other DataFlavors
 are supported.
- Since:
- 1.1
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionStringSelection(String data) Creates aTransferablecapable of transferring the specifiedString.
- 
Method SummaryModifier and TypeMethodDescriptiongetTransferData(DataFlavor flavor) Returns theTransferable's data in the requestedDataFlavorif possible.Returns an array of flavors in which thisTransferablecan provide the data.booleanisDataFlavorSupported(DataFlavor flavor) Returns whether the requested flavor is supported by thisTransferable.voidlostOwnership(Clipboard clipboard, Transferable contents) Notifies this object that it is no longer the clipboard owner.
- 
Constructor Details- 
StringSelectionCreates aTransferablecapable of transferring the specifiedString.- Parameters:
- data- the string to be transferred
 
 
- 
- 
Method Details- 
getTransferDataFlavorsReturns an array of flavors in which thisTransferablecan provide the data.DataFlavor.stringFlavoris properly supported. Support forDataFlavor.plainTextFlavoris deprecated.- Specified by:
- getTransferDataFlavorsin interface- Transferable
- Returns:
- an array of length two, whose elements are
         DataFlavor.stringFlavorandDataFlavor.plainTextFlavor
 
- 
isDataFlavorSupportedReturns whether the requested flavor is supported by thisTransferable.- Specified by:
- isDataFlavorSupportedin interface- Transferable
- Parameters:
- flavor- the requested flavor for the data
- Returns:
- trueif- flavoris equal to- DataFlavor.stringFlavoror- DataFlavor.plainTextFlavor;- falseif- flavoris not one of the above flavors
- Throws:
- NullPointerException- if- flavoris- null
 
- 
getTransferDataReturns theTransferable's data in the requestedDataFlavorif possible. If the desired flavor isDataFlavor.stringFlavor, or an equivalent flavor, theStringrepresenting the selection is returned. If the desired flavor isDataFlavor.plainTextFlavor, or an equivalent flavor, aReaderis returned.
 Note: The behavior of this method forDataFlavor.plainTextFlavorand equivalentDataFlavors is inconsistent with the definition ofDataFlavor.plainTextFlavor.- Specified by:
- getTransferDatain interface- Transferable
- Parameters:
- flavor- the requested flavor for the data
- Returns:
- the data in the requested flavor, as outlined above
- Throws:
- UnsupportedFlavorException- if the requested data flavor is not equivalent to either- DataFlavor.stringFlavoror- DataFlavor.plainTextFlavor
- IOException- if an IOException occurs while retrieving the data. By default, StringSelection never throws this exception, but a subclass may.
- NullPointerException- if- flavoris- null
- See Also:
 
- 
lostOwnershipDescription copied from interface:ClipboardOwnerNotifies this object that it is no longer the clipboard owner. This method will be called when another application or another object within this application asserts ownership of the clipboard.- Specified by:
- lostOwnershipin interface- ClipboardOwner
- Parameters:
- clipboard- the clipboard that is no longer owned
- contents- the contents which this owner had placed on the- clipboard
 
 
-