wood burning stoves 2.0*
The moose likes Applets and the fly likes Drag and Drop not working in Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Drag and Drop not working in Applet" Watch "Drag and Drop not working in Applet" New topic
Author

Drag and Drop not working in Applet

Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
I have an object called ColorBar that extends JPanel (i.e., is serializable). In my app, one can drag a one ColorBar over to another and drop it.

The functionality works in Eclipse, running both as Application or Applet. The functionality works when running as an application from a jar. But I get an error when trying to run as an Applet via all my browsers, including running from a "web folder" on a local drive that mirrors my web site. The rest of the applet works fine.

Here is the first part of the error message:


Here is the code in the vicinity of ColorBar, line 87:

Line 87 is the instantiation of colorBarFlavor.
This code is within the constructor for ColorBar.

I've also tried using the following instead of relying on this.getClass().getName()


There are six ColorBars in the app. When running as an JApplet, the Java Console displays 6 copies of the error message I cited. These errors don't occur when running in Eclipse or from a command line & jar.

Any thoughts as to why my code does not work? I am using a form of DataFlavor creation that is recommended in the Java Tutorials.

The error says that from within "tryingToLoadClass" it cannot find ColorBar, yes? Why would this not work only in JApplet/browser context? Is there some significance about the appearance of "/" in the error message instead of "."? When I use "/" in the second way of specifying the class, the DataFlavor constructor throws an error saying it cannot parse the String, and if I put the name in quotes, including the "/" instead of "." separators, then the application also fails to find the class.

Could the mistake be in defining the DataFlavor before the class constructor is completed? I just tried moving the DataFlavor and following TransferHandler code to a separate method, called after instantiation, but am getting the same error in the web viewing (but not in the application or Eclipse applet viewer context).

I'm guessing there's something I'm not aware of pertaining to naming classes that has to do with the applet/browser context, but am currently stumped.

Adding a bit more info, thought it might help.
Package is defined as follows:


Picture of project structure tree from Eclipse:


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drag and Drop not working in Applet
 
Similar Threads
Applet doesn't load
TransferHandler exception for Mac OS
reference problem in drag and drop
How to set a dataflavor to a component?
REWARD : pass a2a parameter, involves using getCodeBase()