• Post Reply Bookmark Topic Watch Topic
  • New Topic

Double JDialog question

 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have two JDialogs open, which are not modal, and I want to close BOTH of them if the user clicks outside either of the two JDialogs, how might I go about this? I have no problem doing this with a single JDialog, as I can just call some sort of hide method inside a WindowAdapter windowDeactivated method, but I can't seem to figure out how to do this with two open JDialogs. My original solution was in each windowDeactivated method, to check if the other JDialog was activated (by setting a flag in the windowActivated method in the other JDialog), but the activation occurs after firing off the windowDeactivated method.
Anyone have any suggestions?
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then try registering a WindowListener object for all other windows/frames and in windowActivated() method of that class, close the two dialog boxes.
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, but what if I click outside the Java application, where no windows of my application are activated? I would like to keep all the logic for keeping windows open/closed within the code of the 2 JDialogs as they should not have to know about anything outside of themselves.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!