EDIT Using DISPOSE_ON_CLOSE is not what I'm after, because them I've got the "inverse" problem: the REPL stays alive when I close the JFrame (which is good) but then it also stays alive when launced from outside the REPL (which is bad).
I'm writing a Swing application in Clojure and I find it convenient to both test thing from the REPL (nrepl under Emacs) and from outside the REPL (for example by using lein run
or by running the standalone .jar).
When I'm not launching my Swing application from the REPL, I find it convenient to set the default close operation to be EXIT_ON_CLOSE. For example:
(.setDefaultCloseOperation jframe JFrame/EXIT_ON_CLOSE)
So I can click on the JFrame's close button and be done with my app.
However apparently (I may be mistaken on this but I think I'm not seeing things) this is problematic when run from the REPL: as soon as I click on the JFrame's close button I apparently kill the nrepl server and have to reopen a new nrepl.
Knowing that I need to both test from nrepl and from outside any REPL, how can I solve my problem?
Should I "detect" that I'm run from a REPL and then not set the default close operation to exit? Or?