Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35461

Re: How do I terminate a JVM properly?

Newsgroups comp.lang.java.programmer
Date 2016-08-25 13:35 -0700
References (2 earlier) <npl47i$1ps$1@dont-email.me> <7b27f662-d2e0-4649-8e4d-5e14e790bd14@googlegroups.com> <e287viFdr8sU1@mid.individual.net> <4fe5062e-9db3-4e91-9cfb-deeb8d51461a@googlegroups.com> <npnig2$jgv$1@dont-email.me>
Message-ID <49be993f-a1dc-4dc8-a034-6d763cf09a8c@googlegroups.com> (permalink)
Subject Re: How do I terminate a JVM properly?
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Thursday, August 25, 2016 at 3:55:57 PM UTC-4, Eric Sosman wrote:
>      Nigel's nailed it.  Quoth the Javadoc for JDialog: "The value is
> set to HIDE_ON_CLOSE by default."  (You've got to hunt a bit for it:
> The text is not in the "up front" material for the class, the way it
> is for JFrame, but down in the setDefaultCloseOperation() description.)

Right...JFrame does tell you it does a hide on close by default right in the top block of the Javadoc while the JDialog is only documented under that method, I just had guessed for the simple sample the default would be to dispose (because who assumes you want to reuse a window after you close it?).

In my app I never use JFrame because JDialog can do everything a JFrame can do but gives you more control, specifically in making windows modal so user can't access a window if an event from that window generates a new window, also giving you control over window decorations like a user should be able to minimize a window but not maximize it (or for a popup window to remove all decorations).  I don't normally care about the default close operation because I always override to do nothing on close, so a window listener can add a popup "Are you sure you want to close?" prompt and do some cleanup.

The confusing part is a JVM never terminates without calling System.exit() if the user has the Java Console visible, unless they click the Close button on that console.  Though everything else is properly disposed, that console holds it open.  In our application (running on a closed source API) that console does close itself, so they must just be exiting.  To write a multi-window standalone app that closes that console I would have to check if there are any displayable windows in my window closing listeners (after disposing current window) then call the exit.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-24 08:14 -0700
  Re: How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-24 14:00 -0700
    Re: How do I terminate a JVM properly? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-24 17:39 -0400
      Re: How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-25 05:24 -0700
        Re: How do I terminate a JVM properly? Nigel Wade <nmw@local.domain> - 2016-08-25 13:52 +0100
          Re: How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-25 06:05 -0700
            Re: How do I terminate a JVM properly? Nigel Wade <nmw@local.domain> - 2016-08-25 15:04 +0100
              Re: How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-25 08:20 -0700
            Re: How do I terminate a JVM properly? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-25 15:55 -0400
              Re: How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-25 13:35 -0700
                Re: How do I terminate a JVM properly? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-25 16:58 -0400
                Re: How do I terminate a JVM properly? Arne Vajhøj <arne@vajhoej.dk> - 2016-08-28 13:29 -0400
                Re: How do I terminate a JVM properly? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-28 13:53 -0400
                Re: How do I terminate a JVM properly? Arne Vajhøj <arne@vajhoej.dk> - 2016-08-28 14:14 -0400
        Re: How do I terminate a JVM properly? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-25 05:52 -0700
    Re: How do I terminate a JVM properly? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-24 18:19 -0400
    Re: How do I terminate a JVM properly? Lew <lewbloch@gmail.com> - 2016-08-24 16:12 -0700
    Re: How do I terminate a JVM properly? Roedy Green <inquiry@mindprod.com> - 2016-08-30 16:34 -0700

csiph-web