-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.2
-
x86
-
windows_nt
Name: rlT66838 Date: 07/06/99
If the Transferable object that you use for Drag and Drop does not contain at least one native transferable, drag and drop between the same JVM will work as expected except it will never call the drop() method on the DropTargetListener.
details for Sun:
inside WDragSourceContextPeer.startDrag(...) you will see a for loop like this:
for (int i = 0 ; i < dfs.length; i++) {
if (!(dfs[i].isRepresentationClassInputStream() ||
dfs[i].isRepresentationClassSerializable() ||
dfs[i].isRepresentationClassRemote() ||
DataFlavor.javaFileListFlavor.equals(dfs[i])))
natives.remove(dfs[i]);
}
if the "natives" Map ends up being empty, the WDropTargetContextPeer.handleDropMessage(...) will never get called which in turn the drop() method will never get called.
This will happen regardless of whether you are dragging within the same JVM or not.
example Transferable that is valid but won't work:
public class ExampleTransferable implements Transferable {
/**
* This is the collection flavor supported for this transferable
*/
public static final DataFlavor collectionDataFlavor = new DataFlavor(Collection.class, "Collection");
private static final DataFlavor[] supportedFlavors = new DataFlavor[] {
collectionDataFlavor
};
private Collection dataObjects;
public ExampleTransferable(Collection dataObjects) {
this.dataObjects = dataObjects;
}
public DataFlavor[] getTransferDataFlavors() {
return supportedFlavors;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
return collectionDataFlavor.equals(flavor);
}
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
if (collectionDataFlavor.equals(flavor)) {
return dataObjects;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
}
(Review ID: 85205)
======================================================================
- duplicates
-
JDK-4251057 Drag and drop of javaJVMLocalObjectMimeType must be serializable
-
- Closed
-