• Post Reply Bookmark Topic Watch Topic
  • New Topic

Drag and Drop not working in Applet  RSS feed

Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!