Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Closing applets

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a JApplet which has a close button. Of course the browser window will close when its clicked.. for some reason.. the dispose() function wont work for me.. help please..
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
me too.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm... you may have a problem because JApplet doesn't have a dispose method... it's a method of Window, and JApplet is not a subclass of Window...

So I've tried to get a reference to the browser window... I called getParent() on an Applet to see if I could make it close the browser window and I could not... I could make the applet disappear off the page, however... I think that this is because the browser window is not a Java Frame (unless the browser was implemented in Java) and thus you cannot get a reference to it to call dispose on...

Anyway... why are you trying to close the browser window through the Applet? This does not make any sense because the user can close the Applet and the browser together by closing the browser window itself... Applets were not meant to be used in this way...

-Nate
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am pretty sure that System.exit(0); will work to close the browser
------------------
Jonathan Brett, SCJP
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm... what browser? System.exit() has thrown a some kind of security exception in every browser I have seen...
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to override the default sercurity permissions in the java.policy file under C:\Program Files\JavaSoft\JRE\1.3.1_08\lib\security
 
Liar, liar, pants on fire! refreshing plug:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic