Plugin Development - Drag and drop HeapByteBuffer error with custom container class

Hi,

I'm writing an IntelliJ IDEA plugin for Android Studio using JavaFX for the GUI. In my project, I have to use drag and drop features in order to create and handle a draggable node. In these operations, I need to use a custom container class and custom data format to save information in ClipboardContent. When I try to retrieve this information using 

DragContainer container = (DragContainer) event.getDragboard().getContent(DragContainer.AddNode);

where DragContainer is my custom container class (implements Serializable) and AddNode is custom data format, the following error occurs:

Java Messsge:java.nio.HeapByteBuffer cannot be cast to template.sample.DragContainer
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: java.nio.HeapByteBuffer cannot be cast to template.sample.DragContainer

Differently, when I try to execute the same code in a JavaFX Application (not in an IntelliJ Platform Plugin project as I need) all work correctly without this error.

Do you know how can I fix it, please???

Thank you

0
2 comments

Hello, did you find the solution for this problem?

0

This is strange. According to docs of Clipboard, getContent  - "Returns the content stored in this clipboard of the given type, or null if there is no content with this type." meaning your DataFormat is wrong, or something works wrong in javaFx. 

I guess only debugging can help here.

0

Please sign in to leave a comment.