Solved

destroying a Frame, from an applet

Posted on 1998-02-17
4
278 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now