> currently we are trying to convert a java gui program into an applet.
> now that we are inheriting from JApplet we have the following error
[quoted text clipped - 14 lines]
>
> Means the instance could not be created....
Looking at the top of the stack trace, the exception is coming from
Class.newInstance. If we check the docs we see:
"InstantiationException - if this Class represents an abstract class, an
interface, an array class, a primitive type, or void; or if the class
has no nullary constructor; or if the instantiation fails for some other
reason."
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#newInstance()
So presumably FLGPlotter2D does not have a no-args constructor. Not a
very friendly error report.
> Is there a problem running threads in Applets?
> What else could cause the failure?
There are the usual Swing threading issues. For Swing you should extend
javax.swing.JApplet instead of java.applet.Applet directly, as you say.
Apparently for historical reasons, some applet methods are called
outside of the Event Dispatch Thread (EDT). Therefore you need a
fantastical bit of boilerplate before accessing Swing components (or AWT
components if you want to be safe).
@Override
public void init() {
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
// ...fiddle with components here...
}
});
} catch (java.lang.InterruptedException exc) {
// I assume you are not using Thread.interrupt.
// May come from applet shutdown sequence.
// Just swallow interrupted state and exit init.
// ... or your error handling here ...
} catch (java.lang.reflect.InvocationTargetException exc) {
// Must be an unchecked exception - throw unwrapped.
if (exc instanceof RuntimeException) {
throw (RuntimeException)exc;
} else if (exc instanceof Error) {
throw (Error)exc;
} else {
throw new Error(
"...your comment about this being impossible...",
exc.getCause()
);
}
// ... or your error handling here ...
}
}
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/