|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.eclipse.swt.dnd.Clipboard
| Constructor Summary | |
Clipboard(Display display)
Constructs a new instance of this class. |
|
| Method Summary | |
void |
dispose()
Disposes of the operating system resources associated with the clipboard. |
Object |
getContents(Transfer transfer)
Retrieve the data of the specified type currently available on the system clipboard. |
void |
setContents(Object[] data,
Transfer[] dataTypes)
Place data of the specified type on the system clipboard. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, toString |
| Constructor Detail |
public Clipboard(Display display)
display - the display on which to allocate the clipboard
SWTException - | Method Detail |
public void dispose()
NOTE: On some platforms the data will not be available once the application has exited or the display has been disposed.
public Object getContents(Transfer transfer)
Transfer
to determine the type of object returned.
The following example shows text and RTF text being retrieved from the clipboard:
Clipboard clipboard = new Clipboard(display);
TextTransfer textTransfer = TextTransfer.getInstance();
String textData = (String)clipboard.getContents(textTransfer);
if (textData != null) System.out.println("Text is "+textData);
RTFTransfer rtfTransfer = RTFTransfer.getInstance();
String rtfData = (String)clipboard.getContents(rtfTransfer);
if (rtfData != null) System.out.println("RTF Text is "+rtfData);
clipboard.dispose();
transfer - the transfer agent for the type of data being requested
Transfer
public void setContents(Object[] data,
Transfer[] dataTypes)
NOTE: On some platforms, the data is immediately copied to the system clipboard but on other platforms it is provided upon request. As a result, if the application modifes the data object it has set on the clipboard, that modification may or may not be available when the data is subsequently requested.
The following example shows text and RTF text being set on the clipboard:
Clipboard clipboard=new Clipboard(display);
String textData="Hello World";
String rtfData="{\\rtf1\\b\\i Hello World}";
TextTransfer textTransfer=TextTransfer.getInstance();
RTFTransfer rtfTransfer=RTFTransfer.getInstance();
clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer});
clipboard.dispose();
data - the data to be set in the clipboarddataTypes - the transfer agents that will convert the data to its platform
specific format; each entry in the data array must have a corresponding dataType
IllegalArgumentException - SWTError -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||