Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swing get visible frames

Tags:

java

swing

How can I find all visible frames/dialogs in program? I could subclass JFrame/JDialog classes to update the list of currently visible windows, but if there is a built-in solution for this that would be much better

like image 834
michael nesterenko Avatar asked Dec 09 '22 07:12

michael nesterenko


1 Answers

Try

List<Window> visibleWindows = new ArrayList<Window>();
for(Window w: Window.getWindows()){
    if(w.isShowing()){
        visibleWindows.add(w);
    }
}

References:

  1. getWindows()
  2. isShowing()
like image 85
Moonbeam Avatar answered Dec 28 '22 04:12

Moonbeam