Seems like an applet that is inside a DOM container and getting hidden by calling JQuery’s hide() method messes up the applet’s state.

In my case, I got an IllegalStateException and in some cases forced it to restart the applet which in turned messed up the operation that my code is doing.

I used the deployJava.js script to deploy the applet and enable me to call applet methods from Javascript.

So rather than using hide, user Danny Coulombe of StackOverflow gave a very workable solution. Using CSS, you can use JQuery to add the class attribute to hide or show the applet. See code.

To hide, call $(‘myapplet’).addClass(‘hide’).

To show, call $(‘myapplet’).removeClass(‘hide’).

A very useful solution to preserve your applet state in case you wish to hide it from the user’s view and show it later on using the same instance.

This … was … a … pain. Sure, most forum commenters said that to make this work, you will have to have the attribute Trusted-Library: true in the manifest of your jars and third party jars that your applet uses.

However, that is only half of what needs to be done. Even though all my third party libraries had that attribute in the manifest and signed them I never figured it out until so many days later.

When the Javascript call was made, the annoying warning sign pops up.

So what is the solution?

  1. Make sure all your jars have Trusted-Library: true in the manifest.
  2. Inside your main jar, add another attribute Codebase: *
  3. Sign all your jars using the same certificate

That is it! Problem solved!

I think it started with Java 1.6 that a JNLP jar file was included that can let you run a Java web start application or applet in a single instance.

Through the SingleInstanceService class, you application or applet will be able to detect if another instance is run when it is called from a JNLP.

I have not tried this with an applet that is run from an <APPLET> tag but I tested this in an applet if it is called from a JNLP.

Simply implement SingleInstanceListener from your class and initialize it with this code:

And in the newActivation() method, you can put in a message prompt that looks something like this:

Easy, right?

By the way, if this code is run within an IDE, it will return an exception. This will have to be run from a JNLP in order for it to work.

Related Posts Plugin for WordPress, Blogger...