I need help writing a GUI application that:
• When an attempt is made to close the window, the user should be asked via a dialog to confirm that they indeed wish to terminate the application, via supplying a y (yes) or n (no) indication. If ‘y’ is entered then the application should immediately terminate, if ‘n’ is entered it should stay visible. i almost have this down, but I cant get the window to stay visible after clicking no on the JOptionPane.showConfirmDialog();
• When the user minimises the window by clicking the appropriate icon, a message dialog should appear saying “Minimising the window”
• When the user restores the window, a message dialog should appear saying “Restoring the window”. This would be of great help to me.
For the first part of the question: You can add a
WindowListener
to your application's top levelJFrame
containing the following:... and then implement
doExit()
as follows:In addition you need to add the following method call when initialising your application: