java-gnome version 4.0.19

org.gnome.gtk
Class Clipboard

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gtk.Clipboard

public class Clipboard
extends Object

A mechanism allowing a user to copy data between programs.

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");
 

Since:
4.0.10
Author:
Serkan Kaba, Andrew Cowie
See Also:
The gory historical details that lead to the FreeDesktop clipboard specification

Nested Class Summary
static interface Clipboard.OwnerChange
          This signal is emitted any time the owner of the Clipboard [contents] changes.
 
Method Summary
 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.
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

connect

public void connect(Clipboard.OwnerChange handler)
Hook up a Clipboard.OwnerChange handler.

Since:
4.0.10

getDefault

public static Clipboard getDefault()
Get the default Clipboard.

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.

Since:
4.0.10

getText

public String getText()
Get a textual representation of whatever is in this Clipboard. Some applications use the system clipboard for internal transfer of complex state, so if you've gone and copied some complex vector graphic using an application like Inkscape, you may find that the String you get back from calling this method is a little obscure.

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.

Since:
4.0.10

setImage

public void setImage(Pixbuf pixbuf)
Copy the given image to this Clipboard.

Since:
4.0.10

setText

public void setText(String text)
Copy the given text to this Clipboard.

Since:
4.0.10

store

public 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.

Since:
4.0.17


java-gnome