Solved

destroying a Frame, from an applet

Posted on 1998-02-17
4
283 Views
Last Modified: 2010-04-16
I have a problem where my applet calls up a Frame, but for some reason destroy() (or i'm writing it wrong) never seems to get called, until Netscape is shut down.  So as you surf around, it's still there taking up resources, etc.  

What will cause the applet's destroy() method to be called?

How do I remove the Frame object?

i'm using 1.0.2 by the way.  thanks
0
Comment
Question by:glow060197
  • 2
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1233120
As far as Netscape is concerned, the destroy() method doesn't need to be called until the object is to be cleaned up.  That will certainly occur when the browser is terminated.  You can try and force the JRE engine to clean up by setting your Frame's class variable to null.

Frame myframe;

// Do stuff here...

// Done with it
myframe = null;

It should do the trick (eventually) but there is no guarantee in all environments.
0
 

Author Comment

by:glow060197
ID: 1233121
I tried myframe=null; already (in destroy() at least).  You know how (under win95) the Frames have little X in upper right?  Well that box won't kill it either.  I've created a super-frame somehow...  Maybe an event-handling trick can be hacked?
0
 
LVL 3

Accepted Solution

by:
gwalters earned 70 total points
ID: 1233122
The X won't kill the frame unless you process Event.WINDOW_DESTROY (which is what you get when they click there).

myframe=null; does absolutely nothing.  You don't have to have a reference to a frame for it to be visible.  Don't beleive me?  Try: (new Frame()).show();



To get rid of it:

myframe.hide();
myframe.dispose();

0
 
LVL 3

Expert Comment

by:gwalters
ID: 1233123
BTW, put that in your applet's stop() method and it will go away when they leave your page (I assume that's where you were putting the destroy()).
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question