Clipboard.getContents

Retrieve the data of the specified type currently available on the specified clipboard. Refer to the specific subclass of <code>Transfer</code> to determine the type of object returned.

<p>The following snippet shows text and RTF text being retrieved from the clipboard:</p>

<code><pre> Clipboard clipboard = new Clipboard(display); TextTransfer textTransfer = TextTransfer.getInstance(); String textData = (String)clipboard.getContents(textTransfer); if (textData !is null) System.out.println("Text is "+textData); RTFTransfer rtfTransfer = RTFTransfer.getInstance(); String rtfData = (String)clipboard.getContents(rtfTransfer, DND.CLIPBOARD); if (rtfData !is null) System.out.println("RTF Text is "+rtfData); clipboard.dispose(); </code></pre>

<p>The clipboards value is either one of the clipboard constants defined in class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together (that is, using the <code>int</code> "|" operator) two or more of those <code>DND</code> clipboard constants.</p>

@param transfer the transfer agent for the type of data being requested @param clipboards on which to look for data

@return the data obtained from the clipboard or null if no data of this type is available

@exception SWTException <ul> <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> </ul> @exception IllegalArgumentException <ul> <li>ERROR_NULL_ARGUMENT - if transfer is null</li> </ul>

@see Transfer @see DND#CLIPBOARD @see DND#SELECTION_CLIPBOARD

@since 3.1

  1. Object getContents(Transfer transfer)
  2. Object getContents(Transfer transfer, int clipboards)
    class Clipboard
    Object
    getContents

Meta