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.
In this OldWindow. java write the actual logic code, in this class write the code which creates JFrame, add JButton for open New Frame. In this class write the code which creates JFrame, add JLabel into the New Frame. Simillarly, you can create multiple frames and navigate from one frame to another.
JFrame in Java: Introduction to Java JFrames JFrame is a top-level container that provides a window on the screen. A frame is actually a base window on which other components rely, namely the menu bar, panels, labels, text fields, buttons, etc. Almost every other Swing application starts with the JFrame window.
Ans : add ( ) method.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With