File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes I only want one instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "I only want one instance" Watch "I only want one instance" New topic

I only want one instance

Tharpa Roberts

Joined: Jun 04, 2014
Posts: 4
Here's the situation before I inherited the project: There was an applet with a browse button. There was also another button that was not part of the applet. Clicking on the button launched a process with the selected path as a parameter.

Here's the situation now: I added a set of radio buttons to the applet. Selecting a radio button populates a variable with the selection. However, I have discovered that clicking on the button now launches another instance of the applet, so that the radio selection is not preserved.

What is the best and shortest way to preserve the value of the original selection?
Tony Docherty

Joined: Aug 07, 2007
Posts: 2838
Welcome to the Ranch.

If you want values to persist when the page refreshes then you need to keep a record of the values whenever they are changed and read in these recorded values when the new applet instance loads. You may want to keep record the current date and time as well so you don't load out of date values eg from a session several hours/days ago.

I've never done this before but I think you could do it with cookies. There's a thread here that may get you started.
I agree. Here's the link:
subject: I only want one instance
It's not a secret anymore!