Applet Shutdown Problem

Discussion in 'Java' started by Darol Klawetter, Dec 13, 2005.

  1. My applet runs in its own window frame after being invoked from a
    browser. If I close the applet, the windowClosing event is detected as
    it should be. If I close down the browser instead of the applet, then
    the applet's windowClosing event is not called even though the applet
    closes. I have shutdown code in the windowClosing method and I want
    this code invoked whether I close the applet before the browser or the
    browser before the applet.

    I've tried putting my shutdown code in applet.stop() but the objects I
    need for shutdown have already been deallocated and are thus null
    values when stop() is invoked.

    Any ideas of where I can put my shutdown code?
    Darol Klawetter, Dec 13, 2005
    #1
    1. Advertising

  2. Darol Klawetter

    Vova Reznik Guest

    Read this
    http://java.sun.com/docs/books/tutorial/applet/overview/lifeCycle.html

    What objects are deallocated?

    Darol Klawetter wrote:
    > My applet runs in its own window frame after being invoked from a
    > browser. If I close the applet, the windowClosing event is detected as
    > it should be. If I close down the browser instead of the applet, then
    > the applet's windowClosing event is not called even though the applet
    > closes. I have shutdown code in the windowClosing method and I want
    > this code invoked whether I close the applet before the browser or the
    > browser before the applet.
    >
    > I've tried putting my shutdown code in applet.stop() but the objects I
    > need for shutdown have already been deallocated and are thus null
    > values when stop() is invoked.
    >
    > Any ideas of where I can put my shutdown code?
    >
    Vova Reznik, Dec 13, 2005
    #2
    1. Advertising

  3. Thanks for the link, but it doesn't address my problem.

    Regarding your question: The deallocated objects are my
    application-specific objects, which are primarily java bean objects. It
    appears that they are being unloaded before the applet.stop() is issued.
    Darol Klawetter, Dec 13, 2005
    #3
  4. Darol Klawetter

    Alun Harford Guest

    "Darol Klawetter" <> wrote in message
    news:...
    > My applet runs in its own window frame after being invoked from a
    > browser. If I close the applet, the windowClosing event is detected as
    > it should be. If I close down the browser instead of the applet, then
    > the applet's windowClosing event is not called even though the applet
    > closes. I have shutdown code in the windowClosing method and I want
    > this code invoked whether I close the applet before the browser or the
    > browser before the applet.


    IIRC if somebody closes the browser then they kill the JVM.
    I don't think you can do anything about that.

    Alun Harford
    Alun Harford, Dec 13, 2005
    #4
  5. I've already added a shutdown hook (i.e.,
    Runtime.getRuntime().addShutdownHook()) that should get called before
    the JVM exits but, for some reason, it's not getting called in this
    case.
    Darol Klawetter, Dec 13, 2005
    #5
  6. Darol Klawetter

    Roedy Green Guest

    On 13 Dec 2005 13:14:55 -0800, "Darol Klawetter"
    <> wrote, quoted or indirectly quoted
    someone who said :

    >I've already added a shutdown hook (i.e.,
    >Runtime.getRuntime().addShutdownHook()) that should get called before
    >the JVM exits but, for some reason, it's not getting called in this
    >case.


    There is a good chance you need to be signed to do that.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Dec 13, 2005
    #6
  7. Roedy Green wrote:
    > On 13 Dec 2005 13:14:55 -0800, "Darol Klawetter"
    > <> wrote, quoted or indirectly quoted
    > someone who said :
    >
    > >I've already added a shutdown hook (i.e.,
    > >Runtime.getRuntime().addShutdownHook()) that should get called before
    > >the JVM exits but, for some reason, it's not getting called in this
    > >case.

    >
    > There is a good chance you need to be signed to do that.
    > --
    > Canadian Mind Products, Roedy Green.
    > http://mindprod.com Java custom programming, consulting and coaching.



    I've given my applet full permission on my machine via the policy file.
    Any other ideas?
    Darol Klawetter, Dec 14, 2005
    #7
  8. Any other ideas? Anyone?
    Darol Klawetter, Dec 14, 2005
    #8
  9. Darol Klawetter wrote:
    > Any other ideas? Anyone?


    Browsers cannot be relied upon to call Applet.stop(), it is
    that simple. If you need more control, wrap the applet in JWS,
    then you have the more predictable AppletViewer showing the applet.

    --
    Andrew Thompson
    physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
    Andrew Thompson, Dec 16, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert May

    Shutdown a single ASP.net process.

    Robert May, Oct 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    360
    Alvin Bruney
    Oct 19, 2003
  2. JBMC

    Cannot shutdown W3SVC

    JBMC, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    6,848
  3. Pint

    prevent application shutdown

    Pint, Mar 16, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    2,053
    Brock Allen
    Mar 17, 2005
  4. Rune Andresen
    Replies:
    2
    Views:
    1,932
    Phil Powell
    Sep 17, 2003
  5. Holger Joukl
    Replies:
    0
    Views:
    424
    Holger Joukl
    Apr 23, 2004
Loading...

Share This Page