r/JavaFX • u/EdwardAlgorist • Feb 15 '22
Tutorial JavaFX Confirming Application Exit
https://codewithedward.com/javafx-confirming-application-exit/
6
Upvotes
5
u/iazarny Feb 16 '22
More correct way to terminate application use
stage.setOnCloseRequest( event -> { Platform.exit(); } );
2
u/hamsterrage1 Feb 16 '22
I don't think you need to do that. Simply letting the event bubble back up to the Stage will trigger
Platform.exit(), won't it?This tutorial is really more about swallowing up the request if the user doesn't respond with "Yes, I am" to a "Are you sure you want to do this?" prompt.
2
u/hamsterrage1 Feb 16 '22
I think it's bad form to use Optional.get(). Something like:
Would be better.