View page on GitHub

Test Applet Init Notification

Applets are not ready right away, this demonstrates one approach to handle that

Run Init Notification

Methods on applets cannot be called right away from Javascript. Additionally currently in some browsers the Javascript object for the applet cannot even be accessed too soon. The Timing Test shows problems with a naive approach to working applets.

This code demonstrates a way to deal with this by having the applet notify javascript when it is ready.

One caution with this approach is to watch out for threading issues if you try to make round trip calls from java to javascript and back again. The jdk8 applet execution guide implies that can cause problems.

I’ve also seen issues on IE where a exception is thrown when the plugin tries to run the applet start method. This might be related to this approach of calling JSObject.getWindow in the init method. However running this specific test does not have that problem. But it could be related to how the applet is added to the page and the complexity of the page. It might be safer to call back to javascript in the start method instead of the init method.