I'm running into a bit of a problem. I'm creating a program for a client. In the program, I have implement a dedicated 'close/shut down' button - which requires a password in order to properly shut down. But an alternative (and less safe) way of closing the program is by hitting the red close or 'X' button: top right (Windows) or top left(Mac).
I do not want the red x button to actually close the entire program. What I would like to know: is it possible to completely disable the red 'x' button from closing the entire program? If possible, could someone provide code for this?
What I'm using: IntelliJ IDEA (Ultimate), JavaFX with Java 8, Dev. Language: Java
Add a event handler to the
onCloseRequest
event of the stage. This allows you to prevent the window from closing by consuming the event and executing your own shutdown procedure instead: