Class FileDrop.TransferableObject

java.lang.Object
com.iamsoft.util.ui.swing.FileDrop.TransferableObject
All Implemented Interfaces:
Transferable
Enclosing class:
FileDrop

public static class FileDrop.TransferableObject extends Object implements Transferable
At last an easy way to encapsulate your custom objects for dragging and dropping in your Java programs! When you need to create a Transferable object, use this class to wrap your object. For example:

      ...
      MyCoolClass myObj = new MyCoolClass();
      Transferable xfer = new TransferableObject( myObj );
      ...
 
Or if you need to know when the data was actually dropped, like when you're moving data out of a list, say, you can use the FileDrop.TransferableObject.Fetcher inner class to return your object Just in Time. For example:

      ...
      final MyCoolClass myObj = new MyCoolClass();

      TransferableObject.Fetcher fetcher = new TransferableObject.Fetcher()
      {   public Object getObject(){ return myObj; }
      }; // end fetcher

      Transferable xfer = new TransferableObject( fetcher );
      ...
 
The DataFlavor associated with FileDrop.TransferableObject has the representation class net.iharder.dnd.TransferableObject.class and MIME type application/x-net.iharder.dnd.TransferableObject. This data flavor is accessible via the static DATA_FLAVOR property.

I'm releasing this code into the Public Domain. Enjoy.

Version:
1.2