Java clipboardOwner Purpose?

I wrote a Java application that copies a string to the system clipboard. The constructor uses

Clipboard.setContents(Transferable contents, ClipboardOwner owner) 

http://docs.oracle.com/javase/6/docs/api/java/awt/datatransfer/Clipboard.html

I did it, but I'm not sure what ClipboardOwner does? Looking at the Java api, there is actually not much information.

http://docs.oracle.com/javase/6/docs/api/java/awt/datatransfer/ClipboardOwner.html

Oddly enough, even passing ClippboardOwner = null works. So I'm not quite sure what is the matter? Somebody knows?

+7
source share
3 answers

If your application or one of its components implements the ClipboardOwner interface appropriately, it can show you that the user copied some data to the system clipboard from another application or from another component of your own application. See this example .

+3
source

When the next person puts something on the clipboard, the owner to whom you give the clipboard will be told that they are no longer on the clipboard. There is only one known implementation, and it is empty by this . Thus, it looks like a vestigial tail that just hangs.

+2
source

An example of use is the implementation of a terminal window, where any selection is automatically copied to the clipboard. The lostOwnership(..) can be used to lostOwnership(..) , so that the user knows that the selection is displayed if and only if he is currently on the clipboard. This idiom is used, for example, in rxvt (which is not written in Java, however).

0
source

All Articles