Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how can I get my applet to keep its resources after applet.destroy()

Reply
Thread Tools

how can I get my applet to keep its resources after applet.destroy()

 
 
troy makaro
Guest
Posts: n/a
 
      10-06-2005
Hi, I'm using the java plugin version 1.5.0_5 and every time I go from my
web page that has the applet to another web page the applet.destroy() method
occurs and all my resources are closed. My threads are closed, my JFrames
are closed and my PipedInputStream and PipledOutputStream are closed. I
tried storing these resouces in a static field which does keep the objects
but the objects are still dead. Is there any way to keep these resources
alive? Here is a simple test:

public class AppletBase extends JApplet {

public void init() {
JButton button = new JButton("Push me2");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("Title");
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_O N_CLOSE);
frame.getContentPane().add(new JTree());
frame.pack();
frame.setVisible(true);
}
});
getContentPane().setLayout(new FlowLayout());
getContentPane().add(button);

}

}

In the above example, that frame will close when the browser with the applet
goes to another web page. How can I get the frame to stay?
If I can't do it within the applet sandbox how about if I sign the applet?

Troy

Troy


 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      10-07-2005
troy makaro wrote:

> If I can't do it within the applet sandbox how about if I sign the applet?


No. Browsers (should) destroy the applet and resources
on page exit, though the *browser* should also cache
classes and images etcetera.

You might play tricks with putting the series of pages in
'frames' and placing a 'storage applet' in a hidden frame,
but..

When dealing with applets, there is only one thing you can
rely on. Even if you found a way that worked in one browser,
there would be another browser in which it breaks.
 
Reply With Quote
 
 
 
 
troy makaro
Guest
Posts: n/a
 
      10-07-2005
I think the only way to do it is to sign the applet and then create the
resources in a different thread group. I tried this and it does work.
Troy

"troy makaro" <(E-Mail Removed)> wrote in message
news:WRg1f.99552$1i.4803@pd7tw2no...
> Hi, I'm using the java plugin version 1.5.0_5 and every time I go from my
> web page that has the applet to another web page the applet.destroy()
> method occurs and all my resources are closed. My threads are closed, my
> JFrames are closed and my PipedInputStream and PipledOutputStream are
> closed. I tried storing these resouces in a static field which does keep
> the objects but the objects are still dead. Is there any way to keep these
> resources alive? Here is a simple test:
>
> public class AppletBase extends JApplet {
>
> public void init() {
> JButton button = new JButton("Push me2");
> button.addActionListener(new ActionListener() {
> public void actionPerformed(ActionEvent e) {
> JFrame frame = new JFrame("Title");
> frame.setDefaultCloseOperation(JFrame.DO_NOTHING_O N_CLOSE);
> frame.getContentPane().add(new JTree());
> frame.pack();
> frame.setVisible(true);
> }
> });
> getContentPane().setLayout(new FlowLayout());
> getContentPane().add(button);
>
> }
>
> }
>
> In the above example, that frame will close when the browser with the
> applet goes to another web page. How can I get the frame to stay?
> If I can't do it within the applet sandbox how about if I sign the applet?
>
> Troy
>
> Troy
>



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      10-07-2005
troy makaro wrote:

> I think the only way to do it is to sign the applet and then create the
> resources in a different thread group. I tried this and it does work.


<zen question>
In which browser, running which VM?
<zen question>

Where is your page* where I can test that concept
with 4 different browsers running 3 different VM's?

* URL..
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-07-2005
On Thu, 06 Oct 2005 21:41:10 GMT, "troy makaro" <(E-Mail Removed)>
wrote or quoted :

>Is there any way to keep these resources
>alive? Here is a simple test:


Put them in a static. That should survive anything but the
classloader being nullified.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-07-2005
On Thu, 06 Oct 2005 21:41:10 GMT, "troy makaro" <(E-Mail Removed)>
wrote or quoted :

>In the above example, that frame will close when the browser with the applet
>goes to another web page. How can I get the frame to stay?
>If I can't do it within the applet sandbox how about if I sign the applet?


This is a completely different question from how to hold onto loaded
resources. A Frame is not a resource. Even if I knew, I would not
tell you. That would be the Applet from hell.


--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
troy makaro
Guest
Posts: n/a
 
      10-07-2005
I actually don't want a JFrame. I used it as an example that was small. I'm
more concerned with threads and input/output streams. These die even if they
are in a static field as you suggested in a previous post. I am writing a
terminal emulator that I want imedded in an applet not a frame and if a user
goes from one page and to another page and then returns, I want the terminal
emulator to be exactly where it left off.

Troy


"Roedy Green" <(E-Mail Removed) > wrote in
message news:(E-Mail Removed)...
> On Thu, 06 Oct 2005 21:41:10 GMT, "troy makaro" <(E-Mail Removed)>
> wrote or quoted :
>
>>In the above example, that frame will close when the browser with the
>>applet
>>goes to another web page. How can I get the frame to stay?
>>If I can't do it within the applet sandbox how about if I sign the applet?

>
> This is a completely different question from how to hold onto loaded
> resources. A Frame is not a resource. Even if I knew, I would not
> tell you. That would be the Applet from hell.
>
>
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.



 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-07-2005
On Fri, 07 Oct 2005 15:46:33 GMT, "troy makaro" <(E-Mail Removed)>
wrote or quoted :

>I actually don't want a JFrame. I used it as an example that was small. I'm
>more concerned with threads and input/output streams. These die even if they
>are in a static field as you suggested in a previous post. I am writing a
>terminal emulator that I want imedded in an applet not a frame and if a user
>goes from one page and to another page and then returns, I want the terminal
>emulator to be exactly where it left off.


If your app is independent of the browser, perhaps you should cut the
apron strings and allow the browser to terminate without affecting
you.
See http://mindprod.com/jgloss/javawebstart.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      10-08-2005
Roedy Green wrote:
...
> If your app is independent of the browser, perhaps you should cut the
> apron strings and allow the browser to terminate without affecting
> you.
> See http://mindprod.com/jgloss/javawebstart.html


That's a good idea. I do not think this would be practical
as an applet or series of applets.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Its a bird, its a plane, its.. um, an Attribute based System? thunk Ruby 14 04-03-2010 10:08 AM
Its a bird, its a plane, its.. um, an Attribute based System? thunk Ruby 0 04-01-2010 10:25 PM
Its a bird, its a plane, no ummm, its a Ruide thunk Ruby 1 03-30-2010 11:10 AM
Can Groovy be used in an applet and/or can it generate the Java bytecodes that then can be used in an applet? Casey Hawthorne Java 1 03-18-2009 12:56 AM
py2app question: Resources/Python -> Resources/lib/python2.4 Russell E. Owen Python 0 09-08-2006 08:08 PM



Advertisments