Get Any/All Active JFrames in Java Application?

Connor Neville picture Connor Neville · Sep 9, 2011 · Viewed 13.2k times · Source

Is there a way from within a Java application to list all of the currently open/active (I'm not sure the terminology here) JFrames that are visible on screen? Thanks for your help.

Answer

Andrew Thompson picture Andrew Thompson · Sep 9, 2011

Frame.getFrames() returns an array of all frames.

Alternately as mentioned by @mKorbel, Window.getWindows() will return all windows - since Frame (& JFrame) extend Window that will provide all frames, and then some. It will be necessary to iterate them to discover which ones are currently visible.