--- old/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java 2014-07-02 12:28:50.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java 2014-07-02 12:28:50.000000000 +0400 @@ -145,6 +145,16 @@ // non-focused applet. This method can be called from different threads. public void handleWindowFocusEvent(boolean parentWindowActive) { this.parentWindowActive = parentWindowActive; + // If several applets are running in different browser's windows, it is necessary to + // detect the switching between the parent windows and update focusedWindow accordingly. + synchronized (classLock) { + if (parentWindowActive && focusedWindow != this && + (focusedWindow == null || (focusedWindow != null && !focusedWindow.isParentWindowActive()))) { + // It looks like we have switched to another browser window, let's set focus to + // the first applet in this window. + focusedWindow = this; + } + } // ignore focus "lost" native request as it may mistakenly // deactivate active window (see 8001161) if (focusedWindow == this && parentWindowActive) {