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. Advertisements

  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. Advertisements

  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. Advertisements

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. Rob Love

    applet vs. canvas in applet

    Rob Love, Jul 7, 2003, in forum: Java
    Replies:
    1
    Views:
    828
    Liu, Chunyen
    Jul 7, 2003
  2. Blah Blah
    Replies:
    0
    Views:
    1,546
    Blah Blah
    Aug 13, 2003
  3. Jade
    Replies:
    3
    Views:
    1,094
    Roedy Green
    Aug 14, 2003
  4. Rune Andresen
    Replies:
    2
    Views:
    2,187
    Phil Powell
    Sep 17, 2003
  5. Your Name

    Applet to Applet Communication

    Your Name, Nov 3, 2003, in forum: Java
    Replies:
    0
    Views:
    479
    Your Name
    Nov 3, 2003
  6. hyena
    Replies:
    2
    Views:
    2,365
    hyena
    Jul 1, 2004
  7. Krista
    Replies:
    3
    Views:
    2,554
    Andrew Thompson
    Sep 15, 2004
  8. Holger Joukl
    Replies:
    0
    Views:
    528
    Holger Joukl
    Apr 23, 2004
Loading...