Before i close my program (press X on the frame) i wish to have a Conformation message that says something alike: “Are you sure you want to close this window” Followed by a yes and no button.
How exactly can i achieve such a thing?
Ive tried looking up a window listener but not much luck so far.
Where do i exactly play this override Windows listener? I have a seperate view and frame class.
Since i do not wish to add controls for the option pane in my frame.
You must override the method
javax.swing.JFrame.processWindowEvent(WindowEvent)and check for theWindowEvent.WINDOW_CLOSINGevent ID.Display your confirmation dialog and exit only when it returns “Yes”.
Code sample.