java.awt.datatransfer

Class StringSelection

public class StringSelection extends Object implements Transferable, ClipboardOwner

This class transfers a string as plain text using the clipboard.
Constructor Summary
StringSelection(String data)
Transfer the specfied string as text.
Method Summary
ObjectgetTransferData(DataFlavor flavor)
This method returns the data in the requested format.
DataFlavor[]getTransferDataFlavors()
Returns a list of supported data flavors.
booleanisDataFlavorSupported(DataFlavor flavor)
Tests whether or not the specified data flavor is supported.
voidlostOwnership(Clipboard clipboard, Transferable contents)
Called when ownership of the clipboard object is lost.

Constructor Detail

StringSelection

public StringSelection(String data)
Transfer the specfied string as text.

Parameters: data the data for the string selection

Method Detail

getTransferData

public Object getTransferData(DataFlavor flavor)
This method returns the data in the requested format.

Parameters: flavor The desired data flavor.

Returns: The transferred data.

Throws: UnsupportedFlavorException If the specified flavor is not supported. IOException If any other error occurs.

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Returns a list of supported data flavors.

Returns: A list of supported data flavors.

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor flavor)
Tests whether or not the specified data flavor is supported.

Parameters: flavor The data flavor to test.

Returns: true if the data flavor is supported, false otherwise.

lostOwnership

public void lostOwnership(Clipboard clipboard, Transferable contents)
Called when ownership of the clipboard object is lost.

Parameters: clipboard The affected clipboard. contents The clipboard contents.