Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

destroy()

 
Franz Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Regards,
Manfred.
 
Franz Meyer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm.
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
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This does work, I thank you, Roy!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic