Subject: Java Clipboard operations on Linux


>The Java Clipboard APIs seem to follow the paradigm of the Windows
>Clipboard (ie. one application copies text to the clipboard, and then
>another gets the text from the clipboard).

This is platform specific. java-linux port and the sun source code uses the
motif/ lesstiff CLIPBOARD.

Those applications in turn make use of the X server facilities for inter
process communication. You can watch what is happening by running xclipboard
in linux. When you copy in java, say by using ctrl-c on text selected in a
JTextArea,  you will see the text appear in xclipboard window. You  can type
something in the xclipboard window and paste it in java with ctrl-v. This
seems to prove that motif/lesstiff and xclipboard are using the same
CLIPBOARD?

The catch is that applications can do copy and paste through X without using
CLIPBOARD. There are SELECTIONS in X  such as PRIMARY and SECONDARY, and
there are also cut buffers. You can explore these with xcutsel. This allows
transfer of selections between PRIMARY, cut buffers, and CLIPBOARD.

It seems MSWindows platform has standardised on one facility so different
applications apper to communicate. But applications running on X can choose
how to do it.

xterm seems to use PRIMARY. This allows copy by dragging mouse and paste
with button3.

Nestcape 4.5 uses both PRIMARY and CLIPBOARD. When you copy from Nestcape,
you can see the text appears in both CLIPBOARD and PRIMARY. You can paset
into Nestcape from PRIMARY using mouse button3, and paste into netscape from
CLIPBOARD using netscape menu-edit-paste.

Of course all this is may be off topic because the java virtual machine only
has to support copy and paste within the JVM ?

>
>How can these APIs be used to implement Linux-style copy and paste?
>On Linux, the user selects some text in one app, but a copy operation
>is not performed. When a second app tries to get the text, an implicit
>copy is done. But how does one do this from Java?
>

use xcutsel, just run several instances with the different transfer
combinations such as one instance to transfer PRIMARY to cutbuffer, and
another to transfer CLIPBOARD to cutbuffer etc...and watch things with
xclipboard.

There are many traps with X selections as it is left to the applications to
look after things.

If you run all your X applications in an environment which supports a common
method then you may never see any of this - i belive there are some
standardised environments such as CDE? which do this.

Older applications like xterm were written before CLIPBOARD came into use.

All this relates to text. Copying and pasting other objects is another
matter. But in essence there has to be a common understanding between the
two different applications to handle all this.

Books on XLib, Xt and Motif explain all this. xcutsel and xclipboard were
written eons ago, and have been just sitting there waiting for java to be
invented.

>


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to