My applet has trouble executing under Netscape browser. The browser starts executing the init() method and hangs somewhere before finishing it (no error messages or exceptions). As a result the applet's GUI does not get displayed. I was trying to find the reason why the applet hangs but this question is about a different issue.
I noticed that if I reload the hung applet using browser's Reload button (or simply switch to a different page and then come back to the original applet) the applet executes normally. (Browser starts executing init() again and this time finishes it).
My question is whether it is possible to simulate this behavior from within an applet. I cannot use getAppletContext().showDocumnent() since the HTML file for this applet gets build dynamically and does not exist on disk.
What I did was to create a new class RestartApplet() which extended Thread. At the beginning of init() method I created new instance of that class passing it an applet as an argument and call its start() method (start a thread). At the end of init() that thread gets killed.
That thread sleeps for N seconds and then (if its still alive which means init() never finished) tries to restart an applet. I do it by executing the following code:
Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.
Working with files is a moderately common task in Java. For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.
However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly.
Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts.
Introduce Scanner class: