java.awt.datatransfer
Class Clipboard

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.datatransfer.Clipboard

public class Clipboard
extends Object sample code for java.lang.Object definition code for java.lang.Object

A class that implements a mechanism to transfer data using cut/copy/paste operations.

FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener s may be registered on an instance of the Clipboard class to be notified about changes to the set of DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor s available on this clipboard (see addFlavorListener(java.awt.datatransfer.FlavorListener) sample code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) ).

See Also:
Toolkit.getSystemClipboard() sample code for java.awt.Toolkit.getSystemClipboard() definition code for java.awt.Toolkit.getSystemClipboard() , Toolkit.getSystemSelection() sample code for java.awt.Toolkit.getSystemSelection() definition code for java.awt.Toolkit.getSystemSelection()

Field Summary
protected  Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable contents sample code for java.awt.datatransfer.Clipboard.contents definition code for java.awt.datatransfer.Clipboard.contents
           
protected  ClipboardOwner sample code for java.awt.datatransfer.ClipboardOwner definition code for java.awt.datatransfer.ClipboardOwner owner sample code for java.awt.datatransfer.Clipboard.owner definition code for java.awt.datatransfer.Clipboard.owner
           
 
Constructor Summary
Clipboard sample code for java.awt.datatransfer.Clipboard.Clipboard(java.lang.String) definition code for java.awt.datatransfer.Clipboard.Clipboard(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Creates a clipboard object.
 
Method Summary
 void addFlavorListener sample code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) (FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener  listener)
          Registers the specified FlavorListener to receive FlavorEvents from this clipboard.
 DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor [] getAvailableDataFlavors sample code for java.awt.datatransfer.Clipboard.getAvailableDataFlavors() definition code for java.awt.datatransfer.Clipboard.getAvailableDataFlavors() ()
          Returns an array of DataFlavors in which the current contents of this clipboard can be provided.
 Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable getContents sample code for java.awt.datatransfer.Clipboard.getContents(java.lang.Object) definition code for java.awt.datatransfer.Clipboard.getContents(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  requestor)
          Returns a transferable object representing the current contents of the clipboard.
 Object sample code for java.lang.Object definition code for java.lang.Object getData sample code for java.awt.datatransfer.Clipboard.getData(java.awt.datatransfer.DataFlavor) definition code for java.awt.datatransfer.Clipboard.getData(java.awt.datatransfer.DataFlavor) (DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor  flavor)
          Returns an object representing the current contents of this clipboard in the specified DataFlavor.
 FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener [] getFlavorListeners sample code for java.awt.datatransfer.Clipboard.getFlavorListeners() definition code for java.awt.datatransfer.Clipboard.getFlavorListeners() ()
          Returns an array of all the FlavorListeners currently registered on this Clipboard.
 String sample code for java.lang.String definition code for java.lang.String getName sample code for java.awt.datatransfer.Clipboard.getName() definition code for java.awt.datatransfer.Clipboard.getName() ()
          Returns the name of this clipboard object.
 boolean isDataFlavorAvailable sample code for java.awt.datatransfer.Clipboard.isDataFlavorAvailable(java.awt.datatransfer.DataFlavor) definition code for java.awt.datatransfer.Clipboard.isDataFlavorAvailable(java.awt.datatransfer.DataFlavor) (DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor  flavor)
          Returns whether or not the current contents of this clipboard can be provided in the specified DataFlavor.
 void removeFlavorListener sample code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) (FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener  listener)
          Removes the specified FlavorListener so that it no longer receives FlavorEvents from this Clipboard.
 void setContents sample code for java.awt.datatransfer.Clipboard.setContents(java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner) definition code for java.awt.datatransfer.Clipboard.setContents(java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner) (Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable  contents, ClipboardOwner sample code for java.awt.datatransfer.ClipboardOwner definition code for java.awt.datatransfer.ClipboardOwner  owner)
          Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

owner sample code for java.awt.datatransfer.Clipboard.owner

protected ClipboardOwner sample code for java.awt.datatransfer.ClipboardOwner definition code for java.awt.datatransfer.ClipboardOwner  owner

contents sample code for java.awt.datatransfer.Clipboard.contents

protected Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable  contents
Constructor Detail

Clipboard sample code for java.awt.datatransfer.Clipboard(java.lang.String) definition code for java.awt.datatransfer.Clipboard(java.lang.String)

public Clipboard(String sample code for java.lang.String definition code for java.lang.String  name)
Creates a clipboard object.

See Also:
Toolkit.getSystemClipboard() sample code for java.awt.Toolkit.getSystemClipboard() definition code for java.awt.Toolkit.getSystemClipboard()
Method Detail

getName sample code for java.awt.datatransfer.Clipboard.getName() definition code for java.awt.datatransfer.Clipboard.getName()

public String sample code for java.lang.String definition code for java.lang.String  getName()
Returns the name of this clipboard object.

See Also:
Toolkit.getSystemClipboard() sample code for java.awt.Toolkit.getSystemClipboard() definition code for java.awt.Toolkit.getSystemClipboard()

setContents sample code for java.awt.datatransfer.Clipboard.setContents(java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner) definition code for java.awt.datatransfer.Clipboard.setContents(java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner)

public void setContents(Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable  contents,
                        ClipboardOwner sample code for java.awt.datatransfer.ClipboardOwner definition code for java.awt.datatransfer.ClipboardOwner  owner)
Sets the current contents of the clipboard to the specified transferable object and registers the specified clipboard owner as the owner of the new contents.

If there is an existing owner different from the argument owner, that owner is notified that it no longer holds ownership of the clipboard contents via an invocation of ClipboardOwner.lostOwnership() on that owner. An implementation of setContents() is free not to invoke lostOwnership() directly from this method. For example, lostOwnership() may be invoked later on a different thread. The same applies to FlavorListeners registered on this clipboard.

The method throws IllegalStateException if the clipboard is currently unavailable. For example, on some platforms, the system clipboard is unavailable while it is accessed by another application.

Parameters:
contents - the transferable object representing the clipboard content
owner - the object which owns the clipboard content
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if the clipboard is currently unavailable
See Also:
Toolkit.getSystemClipboard() sample code for java.awt.Toolkit.getSystemClipboard() definition code for java.awt.Toolkit.getSystemClipboard()

getContents sample code for java.awt.datatransfer.Clipboard.getContents(java.lang.Object) definition code for java.awt.datatransfer.Clipboard.getContents(java.lang.Object)

public Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable  getContents(Object sample code for java.lang.Object definition code for java.lang.Object  requestor)
Returns a transferable object representing the current contents of the clipboard. If the clipboard currently has no contents, it returns null. The parameter Object requestor is not currently used. The method throws IllegalStateException if the clipboard is currently unavailable. For example, on some platforms, the system clipboard is unavailable while it is accessed by another application.

Parameters:
requestor - the object requesting the clip data (not used)
Returns:
the current transferable object on the clipboard
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if the clipboard is currently unavailable
See Also:
Toolkit.getSystemClipboard() sample code for java.awt.Toolkit.getSystemClipboard() definition code for java.awt.Toolkit.getSystemClipboard()

getAvailableDataFlavors sample code for java.awt.datatransfer.Clipboard.getAvailableDataFlavors() definition code for java.awt.datatransfer.Clipboard.getAvailableDataFlavors()

public DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor [] getAvailableDataFlavors()
Returns an array of DataFlavors in which the current contents of this clipboard can be provided. If there are no DataFlavors available, this method returns a zero-length array.

Returns:
an array of DataFlavors in which the current contents of this clipboard can be provided
Throws:
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this clipboard is currently unavailable
Since:
1.5

isDataFlavorAvailable sample code for java.awt.datatransfer.Clipboard.isDataFlavorAvailable(java.awt.datatransfer.DataFlavor) definition code for java.awt.datatransfer.Clipboard.isDataFlavorAvailable(java.awt.datatransfer.DataFlavor)

public boolean isDataFlavorAvailable(DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor  flavor)
Returns whether or not the current contents of this clipboard can be provided in the specified DataFlavor.

Parameters:
flavor - the requested DataFlavor for the contents
Returns:
true if the current contents of this clipboard can be provided in the specified DataFlavor; false otherwise
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if flavor is null
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this clipboard is currently unavailable
Since:
1.5

getData sample code for java.awt.datatransfer.Clipboard.getData(java.awt.datatransfer.DataFlavor) definition code for java.awt.datatransfer.Clipboard.getData(java.awt.datatransfer.DataFlavor)

public Object sample code for java.lang.Object definition code for java.lang.Object  getData(DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor  flavor)
               throws UnsupportedFlavorException sample code for java.awt.datatransfer.UnsupportedFlavorException definition code for java.awt.datatransfer.UnsupportedFlavorException ,
                      IOException sample code for java.io.IOException definition code for java.io.IOException 
Returns an object representing the current contents of this clipboard in the specified DataFlavor. The class of the object returned is defined by the representation class of flavor.

Parameters:
flavor - the requested DataFlavor for the contents
Returns:
an object representing the current contents of this clipboard in the specified DataFlavor
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if flavor is null
IllegalStateException sample code for java.lang.IllegalStateException definition code for java.lang.IllegalStateException - if this clipboard is currently unavailable
UnsupportedFlavorException sample code for java.awt.datatransfer.UnsupportedFlavorException definition code for java.awt.datatransfer.UnsupportedFlavorException - if the requested DataFlavor is not available
IOException sample code for java.io.IOException definition code for java.io.IOException - if the data in the requested DataFlavor can not be retrieved
Since:
1.5
See Also:
DataFlavor.getRepresentationClass() sample code for java.awt.datatransfer.DataFlavor.getRepresentationClass() definition code for java.awt.datatransfer.DataFlavor.getRepresentationClass()

addFlavorListener sample code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener)

public void addFlavorListener(FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener  listener)
Registers the specified FlavorListener to receive FlavorEvents from this clipboard. If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the listener to be added
Since:
1.5
See Also:
removeFlavorListener(java.awt.datatransfer.FlavorListener) sample code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) , getFlavorListeners() sample code for java.awt.datatransfer.Clipboard.getFlavorListeners() definition code for java.awt.datatransfer.Clipboard.getFlavorListeners() , FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener , FlavorEvent sample code for java.awt.datatransfer.FlavorEvent definition code for java.awt.datatransfer.FlavorEvent

removeFlavorListener sample code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener)

public void removeFlavorListener(FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener  listener)
Removes the specified FlavorListener so that it no longer receives FlavorEvents from this Clipboard. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this Clipboard. If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the listener to be removed
Since:
1.5
See Also:
addFlavorListener(java.awt.datatransfer.FlavorListener) sample code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) , getFlavorListeners() sample code for java.awt.datatransfer.Clipboard.getFlavorListeners() definition code for java.awt.datatransfer.Clipboard.getFlavorListeners() , FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener , FlavorEvent sample code for java.awt.datatransfer.FlavorEvent definition code for java.awt.datatransfer.FlavorEvent

getFlavorListeners sample code for java.awt.datatransfer.Clipboard.getFlavorListeners() definition code for java.awt.datatransfer.Clipboard.getFlavorListeners()

public FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener [] getFlavorListeners()
Returns an array of all the FlavorListeners currently registered on this Clipboard.

Returns:
all of this clipboard's FlavorListeners or an empty array if no listeners are currently registered
Since:
1.5
See Also:
addFlavorListener(java.awt.datatransfer.FlavorListener) sample code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.addFlavorListener(java.awt.datatransfer.FlavorListener) , removeFlavorListener(java.awt.datatransfer.FlavorListener) sample code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) definition code for java.awt.datatransfer.Clipboard.removeFlavorListener(java.awt.datatransfer.FlavorListener) , FlavorListener sample code for java.awt.datatransfer.FlavorListener definition code for java.awt.datatransfer.FlavorListener , FlavorEvent sample code for java.awt.datatransfer.FlavorEvent definition code for java.awt.datatransfer.FlavorEvent