O'Reilly logo

Core Java® Volume II—Advanced Features, Ninth Edition by Gary Cornell, Cay S. Horstmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.13.6. Using a Local Clipboard to Transfer Object References

Occasionally, you might need to copy and paste a data type that isn’t one of the data types supported by the system clipboard and that isn’t serializable. To transfer an arbitrary Java object reference within the same JVM, use the MIME type

application/x-java-jvm-local-objectref;class=className

You need to define a Transferable wrapper for this type. The process is entirely analogous to the SerialTransferable wrapper of the preceding example.

An object reference is only meaningful within a single virtual machine. For that reason, you cannot copy the shape object to the system clipboard. Instead, use a local clipboard:

Clipboard clipboard = new Clipboard("local");

The construction parameter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required