Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting a list of currently opened JFrames and JDialogs  RSS feed

 
David Irwin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • 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
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Nathan; that's exactly what I was looking for.

Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!