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?
Then try registering a WindowListener object for all other windows/frames and in windowActivated() method of that class, close the two dialog boxes.
posted 14 years ago
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.
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad: