Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Multiple Applets - unpredictable output

 
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

 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend fixing the NPE first and then see how it goes.
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic