O'Reilly logo

JavaBeans Unleashed by Rick Leinecker, Dr. Donald Doherty

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

The Transferable Object

The java.awt.datatransfer.StringSelection class works well for transfers within the same JVM but experiences a ClassCastException when used in inter-JVM cases. To solve this problem, you will have to provide a custom Transferable object.

A custom Transferable object creates instances of the DataFlavors it wants to provide. The getTransferDataFlavors() method is directed by the Transferable interface to return an array of these flavors. To facilitate the implementation of isDataFlavorSupported(DataFlavor), create a java.util.List representation of this array.

This example provides two flavors, and you can use the two predefined DataFlavor flavors because you are simply transferring text data. You can use DataFlavor. stringFlavor ...

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