public class Clipboard extends Object
Clipboards were originally for sharing data between different processes, but of course conventional practise these days is that cut, copy and paste are used quite ubiquitously both as a way to copy things from one program to another, as well as simply moving data around within an application.
You can copy text to the main system Clipboard quite simply, as follows:
clipboard = Clipboard.getDefault(); clipboard.setText("Hello there");
Modifier and Type | Class and Description |
---|---|
static interface |
Clipboard.OwnerChange
This signal is emitted any time the owner of the Clipboard [contents]
changes.
|
Modifier and Type | Method and Description |
---|---|
void |
connect(Clipboard.OwnerChange handler)
Hook up a
Clipboard.OwnerChange handler. |
static Clipboard |
getDefault()
Get the default Clipboard.
|
String |
getText()
Get a textual representation of whatever is in this Clipboard.
|
void |
setImage(Pixbuf pixbuf)
Copy the given image to this Clipboard.
|
void |
setText(String text)
Copy the given text to this Clipboard.
|
void |
store()
Request that the clipboard be copied somewhere outside your process's
memory so that it will remain accessible to other applications after
your process has terminated.
|
public void connect(Clipboard.OwnerChange handler)
Clipboard.OwnerChange
handler.public static Clipboard getDefault()
There are actually quite a number of different clipboards in the X
server! Normal people are used to there only being one, and current
conventions are that the CLIPBOARD
clipboard is the
one that cut, copy, and paste operations go to. That is the clipboard
returned here.
public String getText()
This call blocks until the text is available, though the main loop may iterate while it is doing so.
The underlying implementation is actually asynchronous; a request for the data has to be made through the X server to whatever application actually placed the data in the clipboard.
public void setImage(Pixbuf pixbuf)
public void setText(String text)
public void store()