Drag and Drop API for Swing App

User e951339c43

25-03-2013 18:02:29

Hello, the Marvin Sketch application allows the user to drag and drop a file (cdx, skc, mrv, etc.) and open it automatically. I see that in Marvin-gui.jar there is a class named chemaxon.marvin.common.swing.DnD. Is this the class used for this feature? How do I enable this feature for my own Swing desktop application? Thanks for your help!

ChemAxon 5433b8e56b

26-03-2013 13:26:28

Hi,


the DnD class and all its descendants is private chemaxon API (it is not included in our documentation) and is a subject to change in any release, so I am suggesting not to rely on its functionality at all.


If you have a swing application, that is using MarvinSketch or MarvinView as an embedded part of it, then it will work aoutmatically inside the MarvinSketch and/or MarvinView canvas just as copy and paste.


If you need to have structure file drag and drop functionality elsewhere in your app and you would like to use Marvin API to handle the structure import for you, then you can use the ClipboardHandler class and its getObjectFromTransferable method, which returns a Molecule object except if the clipboard content is a pdb file, in this case it returns a MacroMolecule object (you need to cast the return value from object).


You need to set up the drag and drop functionality according to the java standards for your app on your own, for example by adding a TransferHandler to your swing components. You can find documentation on this in the swing tutorial.


I hope this helps to clarify your possibilities. If you have any further question please do not hesitate to ask.


Regards,
IstvanĀ