- public class XClipboard
- extends java.lang.Object
Implements some X-specific methods for cut and paste.
The X Window System has several mechanisms to support cut
This class provides some simple methods for extracting
text selection strings. It can be subclassed to support more
generality: the protected readSelection() method can support
arbitrary selection atom names and arbitrary target types.
More information than you could ever want to know about this can
be found in the XConvertSelection() man page and the ICCCM
- CLIPBOARD selection
- This is the mechanism used by applications that implement an
explicit cut and paste mechanism. It's used
by the java.awt.datatransfer.Clipboard methods.
- PRIMARY selection
- This is the mechanism used when you simply drag a selection without
cutting or copying. For example, when you drag a selection in one
terminal window and paste it into another with the middle mouse button,
you're using primary selection.
- SECONDARY selection
- An adjunct to the primary selection mechanism.
- An outdated way of moving data around. Unlike selection, which
supports moving arbitrary data types through an active transfer
between programs, the cutbuffer statically stores text data in
properties on the root window. Tends to be used only by ancient
- Nathan Meyers
Hold platform-specific data here: X window connection and
The class constructor opens a connection to the X server.
Shut down the X connection at finalization.
A simple test of the selection mechanisms.
Read the clipboard selection as a string.
Read the contents of CutBuffer0.
Read the primary selection as a string.
Read the secondary selection as a string.
Request and read the current selection.
|Methods inherited from class java.lang.Object
protected byte privateXData
- Hold platform-specific data here: X window connection and
- The class constructor opens a connection to the X server. Since
Java will not share its X connections, XClipboard needs one of
protected void finalize()
- Shut down the X connection at finalization.
- finalize in class java.lang.Object
public byte readCutBuffer0()
- Read the contents of CutBuffer0. This is an ancient X cut/paste
mechanism, and of very limited use.
protected java.lang.Object readSelection(byte dp,
- Request and read the current selection. The entire selection
is read and returned, rather than setting up an InputStream
mechanism to pump the bits as needed (which might be preferable
for big selections).
This protected class is not the primary interface,
but supports adding generality not supported by the various
dp - The private X data created by the class constructor.
selection - The selection being requested - name of an X
atom. The usual cut/paste buffer is "PRIMARY". Also of interest:
"SECONDARY" and "CLIPBOARD".
target - The target type - name of an X atom. "STRING" is
the most common.
- a byte, short, or int with the selection value.
The type is determined by the type returned by the selection.
public java.lang.String readPrimarySelectionString()
- Read the primary selection as a string.
If an application has some text selected, this will return it.
public java.lang.String readSecondarySelectionString()
- Read the secondary selection as a string.
The secondary selection is rarely used.
public java.lang.String readClipboardSelectionString()
- Read the clipboard selection as a string.
If an application has cut or copied some text,
this will return it. This duplicates, in a limited way, capabilities
public static void main(java.lang.String argv)
- A simple test of the selection mechanisms. Call the four
public read* calls and report any non-null results.