java.awt.datatransfer
Class StringSelection

java.lang.Object
  extended by java.awt.datatransfer.StringSelection
All Implemented Interfaces:
ClipboardOwner, Transferable

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
 Object getTransferData(DataFlavor flavor)
          This method returns the data in the requested format.
 DataFlavor[] getTransferDataFlavors()
          Returns a list of supported data flavors.
 boolean isDataFlavorSupported(DataFlavor flavor)
          Tests whether or not the specified data flavor is supported.
 void lostOwnership(Clipboard clipboard, Transferable contents)
          Called when ownership of the clipboard object is lost.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringSelection

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

Parameters:
data - the data for the string selection
Method Detail

getTransferDataFlavors

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

Specified by:
getTransferDataFlavors in interface Transferable
Returns:
A list of supported data flavors.

isDataFlavorSupported

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

Specified by:
isDataFlavorSupported in interface Transferable
Parameters:
flavor - The data flavor to test.
Returns:
true if the data flavor is supported, false otherwise.

getTransferData

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

Specified by:
getTransferData in interface Transferable
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.
See Also:
DataFlavor.getRepresentationClass()

lostOwnership

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

Specified by:
lostOwnership in interface ClipboardOwner
Parameters:
clipboard - The affected clipboard.
contents - The clipboard contents.