Small problem with status() function
in
Programming Questions
•
2 years ago
Hello all,
I have a slight problem with the status() function in my applet. In the applet,
status() updates an object-specific URL if an object is hovered, otherwise it is reset to an empty string.
The code that resets the browser status is
- if (hovered_object == -1 && online) {
- status("");
- }
So far so good, everything works as expected as long as the applet runs.
However, the funny (or slightly disturbing, depending on one's perspective) thing happens after the applet is quit, e.g. by loading another web page. The Java console outputs the following error (note that the error occurs
after the applet had been quit):
- basic: Stopping applet…
- basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@4dd03ed2
- basic: Destroying applet…
- basic: Disposing applet…
- basic: Joining applet thread…
- basic: Joined applet thread…
- basic: Finding information…
- basic: Releasing classloader: sun.plugin.ClassLoaderInfo@552c8fa8, refcount=0
- basic: Caching classloader: sun.plugin.ClassLoaderInfo@552c8fa8
- basic: Current classloader cache size: 1
- basic: Done…
- basic: Quitting applet…
- Exception in thread "Animation Thread" java.lang.NullPointerException
- at java.applet.Applet.showStatus(Applet.java:224)
- at processing.core.PApplet.status(PApplet.java:2352)
- at library_space.draw(library_space.java:596)
- at processing.core.PApplet.handleDraw(PApplet.java:1606)
- at processing.core.PApplet.run(PApplet.java:1503)
- at java.lang.Thread.run(Thread.java:680)
Line number 596 corresponds exactly to the code above.
If I take a slightly modified example of the processing reference for status():
void draw() { if(mouseX < 50) { status("left"); } else { status(""); } }
everything works fine, no NullPointerException upon applet quit.
What is going on? My assumption is that there is either a timing problem or a memory problem upon stopping the threads. The complete applet code is pretty long, consisting of about 3600 lines of code and using several libraries.
1