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???