static public Frame findActiveFrame ( ) { Frame [ ] frames = JFrame . getFrames ( ) ; for ( Frame frame : frames ) { if ( frame . isVisible ( ) ) return frame ; } return null ; }
thanks to Heinz M . Kabutz