wood burning stoves*
The moose likes Applets and the fly likes destroy() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "destroy()" Watch "destroy()" New topic


Franz Meyer

Joined: Jan 31, 2002
Posts: 17
How to destroy an applet?
Ich have programmed a clock that is counting down till 0. When it stopps counting (when hours, minutes and second are 0) I want the applet to disappear.
But I dont' know how to do so.
PLZ help!

I definetly hate Java! <img src="smile.gif" border="0">
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Franz,
You can't control an applets' life. The idea of an applet is that the browser controls its' life (i.e., when to create, when to destroy). That means whoever controls the browser (usually the user) controls the life of any applet.
If you want your own control, create a frame and then close it when you are done. In that way the user will just see an empty page when your applet has completed.
Franz Meyer

Joined: Jan 31, 2002
Posts: 17
Darn! ^^
Is it possible to usa a frame just the same like an applet? I mean is it working like a window or is it possible to implement a frame just like an applet?
Franz Meyer

Joined: Jan 31, 2002
Posts: 17
Maybe it is possible to hide the applet or to lay it in the background? This would be enough for my programming work!
Franz Meyer

Joined: Jan 31, 2002
Posts: 17
OK, after a little thinking i decided to load another HTML-File.
But what I wnat to know is: How do I load another HTML-File in Applet?
I want to load this File only on my PC so I don't need that URL stuff. The two Files are stored on my Computer.
It would be possible to load the 2nd HTML-File in the 1st one, but I want to try loading it in the JAVA-File.
OK, I have written this Source
String theURLString = new String("myhtml.html");
try {
URL theURL = new URL(theURLString);
getAppletContext().showDocument(theURL, "_top");
catch(MalformedURLException e) {System.out.println(e);}
Problem is, that this Method searches the Internet for the Page. I want it to load it on my hard disc. But how to?
I tried with the hole pathname, but that doesn't work. Maybe someone knows!
THX for help.
[ February 28, 2002: Message edited by: Franz Meyer ]
Franz Meyer

Joined: Jan 31, 2002
Posts: 17
Hey you guys, I really need help. Does anyone understand what I have written up there or is it too confusing to give a clear answer?
If I should describe the problem a bit more, you just have to say it.
I am sure that you guys know what to do about this problem!
So long and thanks for help!
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
maybe you can try to create the URL relative to applet class file.
like this :
new URL(getCodeBase(),"/mypath/the htmlfile.html");
you can also use the getDocumentBase() to get the directory of the html file your applet is in(if the class and the html files are in different directories.)
Franz Meyer

Joined: Jan 31, 2002
Posts: 17
This does work, I thank you, Roy!
I agree. Here's the link: http://aspose.com/file-tools
subject: destroy()
Similar Threads
How to kill an applet
close an applet?
System.exit(0) in destroy()
destroy() method not called
Web Mate