Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

closing applet by clicking button

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to close an applet with click of a button.I tried with system.exit and dispose .Both of them failed.how to do this???
thanks
Srikanth narra
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, an applet can't stand-alone, so it is not possible to close it. Are you mistaken an applet for an application? The closest solution I can think of is as follows:
Create an applet and embed that applet in an html page. Within that applet include a button. When this button is pressed have a window popup (still part of the original applet) and add whatever functionality you want in your "stand-alone" applet into that pop-up frame. Within this frame you can have a button, that when pressed disposes of the frame. That's the best I can offer.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it would be easier to include a button on the web page that pops up a window that contains the applet. In the popup window you can have a button that closes the window.
You can see an example on the Web at http://www.nhn.ou.edu/~walkup/demonstrations/WebAssignments/HarmonicMotion001E.htm . Notice that the "Applet Help" button pops up a window containing some text and a "Close" button. The "Open Applet" button, on the other hand, pops up a window containing an applet. Installing a similar "Close" button on the applet window would be very easy.
Try it and see if this is the kind of functionality you are looking for.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi srikanth,
I used javascript to achieve this and its easier than it seems.
Here are the steps:
import netscape.javascript.*;
//in the actionlistener for the "close" button call destroy()
//in destroy after doing all your cleanup call
JSObject.getWindow(this).eval("javascript:shutDown()");
//the above code will call the javascript function shutDown which should be defined in the <head></head> of your html containing your applet tags.. hope this helps
oh yeah.. in your applet tags you must have this parameter..
<PARAM NAME="MAYSCRIPT" VALUE="true">


[This message has been edited by Charlie Boss (edited July 06, 2001).]
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic