• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Double JDialog question

 
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?
 
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.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!