Disabling [x] button and handling the window close event

Joined
Aug 4, 2008
Messages
1
Reaction score
0
Hi,

I am trying to do the following:
1) Disable all the events when the [X] button is clicked on it, i.e. no operation for the close button.
2) But when user closes it through Ctrl+Alt+Del and ending the program (not the process), I have to catch the event.

I have made the default close operation to

Code:
this.setDefaultCloseOperation( this.DO_NOTHING_ON_CLOSE );


and enabled the events

Code:
enableEvents( AWTEvent.WINDOW_EVENT_MASK );



Code:
protected void processWindowEvent( WindowEvent e )
  {
     super.processWindowEvent( e );
      if ( e.getID() == WindowEvent.WINDOW_CLOSING ) {
    		//I have written  the code for handling event here
      }
   }



Now I could catch the Ctrl+Alt+Del close event, but when I clicked the [X] button, my application is getting closed and the Window Closing event is caught.

Can you guide me in finding out the correct procedure for handling it.

Thanks,
-M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top