- java.lang.Object
- 
- java.awt.datatransfer.StringSelection
 
- 
- All Implemented Interfaces:
- ClipboardOwner,- Transferable
 
 public class StringSelection extends Object implements Transferable, ClipboardOwner ATransferablewhich implements the capability required to transfer aString.This Transferableproperly supportsDataFlavor.stringFlavorand all equivalent flavors. Support forDataFlavor.plainTextFlavorand all equivalent flavors is deprecated. No otherDataFlavors are supported.- Since:
- 1.1
- See Also:
- DataFlavor.stringFlavor,- DataFlavor.plainTextFlavor
 
- 
- 
Constructor SummaryConstructors Constructor Description StringSelection(String data)Creates aTransferablecapable of transferring the specifiedString.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetTransferData(DataFlavor flavor)Returns theTransferable's data in the requestedDataFlavorif possible.DataFlavor[]getTransferDataFlavors()Returns an array of flavors in which thisTransferablecan provide the data.booleanisDataFlavorSupported(DataFlavor flavor)Returns whether the requested flavor is supported by thisTransferable.- 
Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods declared in interface java.awt.datatransfer.ClipboardOwnerlostOwnership
 
- 
 
- 
- 
- 
Constructor Detail- 
StringSelectionpublic StringSelection(String data) Creates aTransferablecapable of transferring the specifiedString.- Parameters:
- data- the string to be transferred
 
 
- 
 - 
Method Detail- 
getTransferDataFlavorspublic DataFlavor[] getTransferDataFlavors() Returns 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
 
 - 
isDataFlavorSupportedpublic boolean isDataFlavorSupported(DataFlavor flavor) Returns 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
 
 - 
getTransferDatapublic Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException Returns 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:
- Reader
 
 
- 
 
-