This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.awt.datatransfer
class Clipboard

java.lang.Object extended by java.awt.datatransfer.Clipboard

Most common way to construct:

Toolkit kit = …;

Clipboard clipboard = kit.getSystemClipboard();

Based on 12 examples


public class Clipboard
extends Object

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

{@link FlavorListener}s may be registered on an instance of the Clipboard class to be notified about changes to the set of {@link DataFlavor}s available on this clipboard (see {@link #addFlavorListener}).


Field Summary
protected Transferable contents
          
protected ClipboardOwner owner
          
 
Constructor Summary

          Creates a clipboard object.
 
Method Summary
 void

          Registers the specified FlavorListener to receive FlavorEvents from this clipboard.
 DataFlavor[]

          Returns an array of DataFlavors in which the current contents of this clipboard can be provided.
 Transferable
getContents(Object requestor)

          Returns a transferable object representing the current contents of the clipboard.
 Object

          Returns an object representing the current contents of this clipboard in the specified DataFlavor.
 FlavorListener[]

          Returns an array of all the FlavorListeners currently registered on this Clipboard.
 String

          Returns the name of this clipboard object.
 boolean

          Returns whether or not the current contents of this clipboard can be provided in the specified DataFlavor.
 void

          Removes the specified FlavorListener so that it no longer receives FlavorEvents from this Clipboard.
 void

          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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contents

protected Transferable contents

owner

protected ClipboardOwner owner
Constructor Detail

Clipboard

public Clipboard(String name)
Creates a clipboard object.

Parameters:
name
Method Detail

addFlavorListener

public synchronized void addFlavorListener(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

getAvailableDataFlavors

public 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

getContents

public synchronized Transferable getContents(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

getData

public Object getData(DataFlavor flavor)
               throws UnsupportedFlavorException,
                      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:
UnsupportedFlavorException - if the requested DataFlavor is not available
IOException - if the data in the requested DataFlavor can not be retrieved

getFlavorListeners

public synchronized 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

getName

public String getName()
Returns the name of this clipboard object.


isDataFlavorAvailable

public boolean isDataFlavorAvailable(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

removeFlavorListener

public synchronized void removeFlavorListener(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

setContents

public synchronized void setContents(Transferable contents,
                                     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


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.