public class Clipboard extends Object
 FlavorListeners may be registered on an instance of the Clipboard class to be notified about changes to the set of DataFlavors available on this clipboard (see addFlavorListener(java.awt.datatransfer.FlavorListener)).
| Modifier and Type | Field | Description | 
|---|---|---|
| protected Transferable | contents | Contents of the clipboard. | 
| protected ClipboardOwner | owner | The owner of the clipboard. | 
| Constructor | Description | 
|---|---|
| Clipboard | Creates a clipboard object. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| void | addFlavorListener | Registers the specified  FlavorListenerto receiveFlavorEvents from this clipboard. | 
| DataFlavor[] | getAvailableDataFlavors() | Returns an array of  DataFlavors in which the current contents of this clipboard can be provided. | 
| Transferable | getContents | Returns a transferable object representing the current contents of the clipboard. | 
| Object | getData | Returns an object representing the current contents of this clipboard in the specified  DataFlavor. | 
| FlavorListener[] | getFlavorListeners() | Returns an array of all the  FlavorListeners currently registered on thisClipboard. | 
| String | getName() | Returns the name of this clipboard object. | 
| boolean | isDataFlavorAvailable | Returns whether or not the current contents of this clipboard can be provided in the specified  DataFlavor. | 
| void | removeFlavorListener | Removes the specified  FlavorListenerso that it no longer receivesFlavorEvents from thisClipboard. | 
| void | setContents | 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. | 
protected ClipboardOwner owner
protected Transferable contents
public Clipboard(String name)
name - for the clipboardpublic String getName()
public void setContents(Transferable contents, ClipboardOwner owner)
 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.
contents - the transferable object representing the clipboard contentowner - the object which owns the clipboard contentIllegalStateException - if the clipboard is currently unavailablepublic Transferable getContents(Object requestor)
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.requestor - the object requesting the clip data (not used)IllegalStateException - if the clipboard is currently unavailablepublic DataFlavor[] getAvailableDataFlavors()
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.DataFlavors in which the current contents of this clipboard can be providedIllegalStateException - if this clipboard is currently unavailablepublic boolean isDataFlavorAvailable(DataFlavor flavor)
DataFlavor.flavor - the requested DataFlavor for the contentstrue if the current contents of this clipboard can be provided in the specified DataFlavor; false otherwiseNullPointerException - if flavor is null
IllegalStateException - if this clipboard is currently unavailablepublic Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
DataFlavor. The class of the object returned is defined by the representation class of flavor.flavor - the requested DataFlavor for the contentsDataFlavor
NullPointerException - if flavor is null
IllegalStateException - if this clipboard is currently unavailableUnsupportedFlavorException - if the requested DataFlavor is not availableIOException - if the data in the requested DataFlavor can not be retrievedpublic void addFlavorListener(FlavorListener listener)
FlavorListener to receive FlavorEvents from this clipboard. If listener is null, no exception is thrown and no action is performed.listener - the listener to be addedpublic void removeFlavorListener(FlavorListener listener)
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.listener - the listener to be removedpublic FlavorListener[] getFlavorListeners()
FlavorListeners currently registered on this Clipboard.FlavorListeners or an empty array if no listeners are currently registered
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.datatransfer/java/awt/datatransfer/Clipboard.html