• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Applets - unpredictable output

 
Steffen Schmitt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody!

I've encountered a somewhat strange Applet behaviour when trying to include multiple Applets in one web page and to control one Applet by the other one. The code is fairly simple:




The source code of Applet2 is trivial:




The web page isn't very sophisticated either:



So why am I sometimes getting this:



or this:



or even this:



on successive invocations (with unpredictable output sometimes even using the same browser) of the web page containing the two applets?


Any suggestions very welcome!

Thanks in advance -


Steffen

 
Maneesh Godbole
Saloon Keeper
Posts: 11342
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed "applet not initialized". What do you get on the Java console?
 
Steffen Schmitt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Maneesh!

The "Applet noninited" is due to a NullPointerException in line 19. Looks like applet2 isn't initialized properly. As it sometimes is, though, could it be a threading issue resulting in a race condition? The whole thing just runs in the event dispatch thread (but this is just a wild guess ...).

It's weird that mostly in Firefox the first run is successful and the applet is displayed properly. When reloading I get the "applet notinited" warning and the second applet isn't shown at all.

Is it possible that jvm can't find applet2? Do I need to specify the classpath via the codebase parameter in the html code? Do I have to specify the package (as the Applet's package isn't the default package but a package named "applets")?

Best regards

Steffen



 
Maneesh Godbole
Saloon Keeper
Posts: 11342
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend fixing the NPE first and then see how it goes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic