variables getting saved between applet instances??

S

shawnn

Hello,

I'm having some strange problems with an applet I wrote. The first time
I launch the applet from a browser all is well. If I quit the applet
and then restart it though some of my variables keep the values they
were assigned in the previous run. This only happens if I use the same
browser window and do not exit the JRE. It's like --

open browser --> open applet --> change setting --> close applet -->
open applet and the setting is changed.

If I close the browser (and thus the JRE) between runs then all is
reset.

Why are variables being saved even after I quit the applet?
 
M

Mickey Segal

Why are variables being saved even after I quit the applet?

Static variables are saved as long as the browser stays open. You need to
explicitly reset static variables if you want them reset. Similarly, the
saved information can be useful in other situations.
 
C

Chris Smith

I'm having some strange problems with an applet I wrote. The first time
I launch the applet from a browser all is well. If I quit the applet
and then restart it though some of my variables keep the values they
were assigned in the previous run.

What do you mean by "quit the applet"? There is no defined way to quit
an applet. An applet has no way of expressing a desire to be "quit."
If you leave a page that has an applet on it, the normal thing thing
that will occur is that stop() will be called, and then start() will be
called when you return to that page. This prevents a bunch of shutdowns
and startups of the VM in a single web site. destroy() is called at
some unspecified time if the browser wants to shut down the applet, but
there is no way for an applet to specifically request that the browser
do that.

Ultimately, you are responsible for performing any initialization in
start() and stop(), or providing the user an explicit means of resetting
the applet to its original state (for example, and button or menu item).

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top