Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enable/Disable Window Close X

 
Emerson Dunne
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application in which I enable and disable the Exit menuItem on the File menu according to the state of the system.
However, currently a user might click the Close "X" button in the upper right hand corner of my JFrame. I'd like to enable and disable this button when I enable/disable the Exit menuItem.
Does anyone know how to do this?
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Emerson Dunne:
I have an application in which I enable and disable the Exit menuItem on the File menu according to the state of the system.
However, currently a user might click the Close "X" button in the upper right hand corner of my JFrame. I'd like to enable and disable this button when I enable/disable the Exit menuItem.
Does anyone know how to do this?

may be this is'nt what u want. You must be having a WindowListener to close the window when X is clicked.
In any case why don't u try removing and adding the listener on the fly? in an event of your interest.
But the X w'd be visible though!
karthik.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Emerson,
No you can't visually enable or disable it. As stated by Karthik, you can use the callback. You will never want to remove it though because the default action is to remove the window. Since you want to use some logic on when to remove the window your listener will always be required! The code below illustrates the feature.

Enjoy,
Manfred.
 
Emerson Dunne
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies. Manfred, I am essentially doing what you suggested... and it will work just fine; however, I was hoping to communicate visually that clicking the [X] will have no effect when it truely will have no effect.
Thanks again for the replies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic