Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

variables getting saved between applet instances??

Thread view: 
shawnn@gmail.com - 22 Mar 2006 03:33 GMT
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?
Mickey Segal - 22 Mar 2006 03:58 GMT
> 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.
Roedy Green - 22 Mar 2006 04:32 GMT
>Why are variables being saved even after I quit the applet?
static or instance variables?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Chris Smith - 22 Mar 2006 06:46 GMT
> 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).

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.