Class Clipboard
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(FlavorListener)).
- Since:
- 1.1
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected TransferableContents of the clipboard.protected ClipboardOwnerThe owner of the clipboard.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddFlavorListener(FlavorListener listener) Registers the specifiedFlavorListenerto receiveFlavorEvents from this clipboard.Returns an array ofDataFlavors in which the current contents of this clipboard can be provided.getContents(Object requestor) Returns a transferable object representing the current contents of the clipboard.getData(DataFlavor flavor) Returns an object representing the current contents of this clipboard in the specifiedDataFlavor.Returns an array of all theFlavorListeners currently registered on thisClipboard.getName()Returns the name of this clipboard object.booleanisDataFlavorAvailable(DataFlavor flavor) Returns whether or not the current contents of this clipboard can be provided in the specifiedDataFlavor.voidremoveFlavorListener(FlavorListener listener) Removes the specifiedFlavorListenerso that it no longer receivesFlavorEvents from thisClipboard.voidsetContents(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.
- 
Field Details- 
ownerThe owner of the clipboard.
- 
contentsContents of the clipboard.
 
- 
- 
Constructor Details- 
ClipboardCreates a clipboard object.- Parameters:
- name- for the clipboard
- See Also:
 
 
- 
- 
Method Details- 
getNameReturns the name of this clipboard object.- Returns:
- the name of this clipboard object
- See Also:
 
- 
setContentsSets 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 ofClipboardOwner.lostOwnership()on that owner. An implementation ofsetContents()is free not to invokelostOwnership()directly from this method. For example,lostOwnership()may be invoked later on a different thread. The same applies toFlavorListeners registered on this clipboard.The method throws IllegalStateExceptionif 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- if the clipboard is currently unavailable
- See Also:
 
- 
getContentsReturns a transferable object representing the current contents of the clipboard. If the clipboard currently has no contents, it returnsnull. The parameter Object requestor is not currently used. The method throwsIllegalStateExceptionif 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- if the clipboard is currently unavailable
- See Also:
 
- 
getAvailableDataFlavorsReturns an array ofDataFlavors in which the current contents of this clipboard can be provided. If there are noDataFlavors 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- if this clipboard is currently unavailable
- Since:
- 1.5
 
- 
isDataFlavorAvailableReturns whether or not the current contents of this clipboard can be provided in the specifiedDataFlavor.- Parameters:
- flavor- the requested- DataFlavorfor the contents
- Returns:
- trueif the current contents of this clipboard can be provided in the specified- DataFlavor;- falseotherwise
- Throws:
- NullPointerException- if- flavoris- null
- IllegalStateException- if this clipboard is currently unavailable
- Since:
- 1.5
 
- 
getDataReturns an object representing the current contents of this clipboard in the specifiedDataFlavor. The class of the object returned is defined by the representation class offlavor.- Parameters:
- flavor- the requested- DataFlavorfor the contents
- Returns:
- an object representing the current contents of this clipboard in
        the specified DataFlavor
- Throws:
- NullPointerException- if- flavoris- null
- IllegalStateException- if this clipboard is currently unavailable
- UnsupportedFlavorException- if the requested- DataFlavoris not available
- IOException- if the data in the requested- DataFlavorcan not be retrieved
- Since:
- 1.5
- See Also:
 
- 
addFlavorListenerRegisters the specifiedFlavorListenerto receiveFlavorEvents from this clipboard. Iflistenerisnull, no exception is thrown and no action is performed.- Parameters:
- listener- the listener to be added
- Since:
- 1.5
- See Also:
 
- 
removeFlavorListenerRemoves the specifiedFlavorListenerso that it no longer receivesFlavorEvents from thisClipboard. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to thisClipboard. Iflistenerisnull, no exception is thrown and no action is performed.- Parameters:
- listener- the listener to be removed
- Since:
- 1.5
- See Also:
 
- 
getFlavorListenersReturns an array of all theFlavorListeners currently registered on thisClipboard.- Returns:
- all of this clipboard's FlavorListeners or an empty array if no listeners are currently registered
- Since:
- 1.5
- See Also:
 
 
-