• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clone Applet

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,
how is it going?
i have a java applet loaded inside a browser. The browser controls many of the functionalities of the applet, and can make modifications to it. That's not the issue...what i am currently doing is creating a button that does a clone of the current window, but the problem is that a fresh new copy of the applet is created inside the new browser with the default settings. What i need to do is to be able to clone the window with the current settings, i.e. if i changed some mode in the initial applet, i want that reflected in the new loaded applet. Any means to do that without the need to save all the current changes into some text file and have the new applet load from that file? this is a troublesome and heavy approach since there might be too many parameters i need to save. So if you know of any means to replicate the currenty opened window into a new one with the settings modified according to the old one, please advice...
Thanks a lot guys..
Best,
Mohammad
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's something that might work...

You can save your settings into Streams using the AppletContext and in your init() method, you can see if these streams exist. If so, you can load the data based on the streams.

Example....
// save a variable

ByteArrayOutputStream baos = new ByteArrayOutputStream ();
ObjectOutputStream oos = new ObjectOutputStream (baos);
oos.writeObject (<object name> ;
oos.close ();

byte [] data = baos.toByteArray ();

is = new ByteArrayInputStream (data);
baos.close ();
getAppletContext ().setStream ("<object name>", is);

In your init() method, check if this stream is null. If not, load it.

InputStream is = getAppletContext ().getStream ("<object name>");
ObjectInputStream ois = null;
if (is != null) {
try {
ois = new ObjectInputStream (is);
<object name> = ((<cast to object type) ois.readObject());
ois.close();
is.close();
}
catch (Exception e) {
e2.printStackTrace(System.out);
}
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic