Skip to main content

Drag and Drop not working on browser

No replies
philfrei
Offline
Joined: 2010-06-04
Points: 0

I have implemented Drag and Drop on an object called a ColorBar in my application. The Drag&Drop works in the application, and as an Applet within the Eclipse IDE, but fails when I try to run the code via a browser. I'm wondering if there are any known issues, or if someone could assist me in trouble-shooting this problem.

Here is the error message:

<br />
java.lang.ClassNotFoundException:<br />
            com/adonax/simplexNoiseVisualizer/color/ColorBar<br />
    at java.lang.Class.forName0(Native Method)<br />
    at java.lang.Class.forName(Unknown Source)<br />
    at java.awt.datatransfer.DataFlavor.tryToLoadClass(Unknown Source)<br />
    at java.awt.datatransfer.DataFlavor.initialize(Unknown Source)<br />
    at java.awt.datatransfer.DataFlavor.<init>(Unknown Source)<br />
    at com.adonax.simplexNoiseVisualizer.<br />
            color.ColorBar.<init>(ColorBar.java:87)<br />

Here is the code in that corresponds:
<br />
    String iAm = this.getClass().getName();<br />
    String colorBarType =<br />
        DataFlavor.javaJVMLocalObjectMimeType<br />
        + ";class=\""<br />
        + iAm + "\"";<br />
    try<br />
    {<br />
        colorBarFlavor = new DataFlavor(colorBarType);<br />
    }<br />
    catch (ClassNotFoundException e)<br />
    {<br />
        e.printStackTrace();<br />
    }<br />

I've also tried spelling out the class verbatim:

<br />
    String colorBarType = DataFlavor.javaJVMLocalObjectMimeType<br />
        + ";class=com.adonax.simplexNoiseVisualizer.color.ColorBar";<br />

The ColorBars are meant to only be dragged from one spot to another within the application.

Any thoughts why the above code works for a .jar and for Eclipse, but not in a browser? I have tried a bunch of things but am running out of ideas. I'm wondering if there have been changes to the security of Applets/Browsers recently that might affect D&D.

The applet is available for viewing at this location (and the error message appears in the Java Console, once for each ColorBar that gets instantiated):
http://www.hexara.com/SimplexBuilder.html

(I don't have a toolbar exposed for formatting the above. I took a stab at putting in tags--hope that helps.)