This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Pipeline as Code and have Mohamed Labouardy on-line!
See this thread for details.
Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Getting a list of currently opened JFrames and JDialogs

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

Is there a Java API method call that will return a list of the currently opened JFrames and JDialogs? In the past I've manually tracked this information in the actual application but I've started work on an existing project that doesn't currently track this. Looking through the Java API nothing jumped out at me.

Thanks,
Dave
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Window.getWindows() (static method) returns all Windows (and Frames, JFrames, Dialogs, and JDialogs are all subclasses of Window). There's Window.getOwnedWindows() (non-static method) to return Windows that are owned by the window that it's called on (passed as a constructor argument). There's also Window.getOwnerlessWindows() (static method) for windows that aren't owned by any other Window. The Frame class also has Frame.getFrames() to get all the Frames (and JFrames) only. Frame.getFrames() and Window.getOwnedWindows() have been around since JDK 1.2, but the other methods have only been added in JDK 1.6.
 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nathan; that's exactly what I was looking for.

Dave
 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic