Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4251057

Drag and drop of javaJVMLocalObjectMimeType must be serializable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2, 1.3.0
    • client-libs
    • generic, x86
    • generic, windows_nt

      Name: mc57594 Date: 06/30/99

      Drag and drop on WinNT and Win95 for local VM objects will only
      work if the object is made Serializable. One would expect that
      local object transfers (which effectively transfer only an obj.
      reference) need not be serializable.

      The following transferable will not work if Serializable is removed. drop(DropTargetDropEvent) on the drop listener
      will never be called by the DnD subsystem.

      public class MyTransferable implements Transferable, ClipboardOwner, Serializable {

      DataFlavor m_df;

      public MyTransferable()
      {

        String mimeType = DataFlavor.javaJVMLocalObjectMimeType +
           "; class=" + this.getClass().getName();

        m_df = new DataFlavor(mimeType, "Davids String");
      }

      public DataFlavor[] getTransferDataFlavors() {
        DataFlavor[] dfs = new DataFlavor[] {m_df};
        return dfs;
      }

      public boolean isDataFlavorSupported( DataFlavor flavor ) {
        return ( flavor.equals(m_df) );
      }
        
      public Object getTransferData(DataFlavor flavor)
        throws UnsupportedFlavorException, IOException {
        if (flavor.equals(m_df))
        {
          return this;
        }
        else
        {
          throw new UnsupportedFlavorException (flavor);
        }
      }

      public String toString() {
        return "MyTransferable";
      }
        
      public void lostOwnership(Clipboard clipboard,
        Transferable contents) {
        System.out.println ("StringTransferable lost ownership of " +
      clipboard.getName());
        System.out.println ("data: " + contents);
      }

      }
      (Review ID: 84940)
      ======================================================================

            dassunw Das Das (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: