A colleague and I are confused about how our Swing desktop app on Mac should exit.

(Please let me know if there’s a better forum to address this question to?)

In QuitHandler the documentation reads:

"Implementors must call either QuitResponse.cancelQuit() <https://docs.oracle.com/en/java/javase/19/docs/api/java.desktop/java/awt/desktop/QuitResponse.html#cancelQuit()>, QuitResponse.performQuit() <https://docs.oracle.com/en/java/javase/19/docs/api/java.desktop/java/awt/desktop/QuitResponse.html#performQuit()>, or ensure the application terminates.”

… but what if our application processes the request to terminate but does not “ensure the application terminates”?

For ex: suppose we initiate a series of user dialogs (“do you want to save your changes?”), but the user clicks “Cancel” to indicate they don’t want to proceed. So we are handling/consuming the quit request responsibly, but technically we haven’t done any of the 3 actions we “must” do.

Is this acceptable? (and if so: should we have a ticket to reword the QuitHandler documentation?)

Or if it is not acceptable: what bad side-effects should we know to test for?

Regards,
 - Jeremy

Reply via email to