--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java Tue May 31 16:03:21 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java Tue May 31 15:57:01 2016 +0300
@@ -148,9 +148,20 @@
Component toFocus =
KeyboardFocusManager.getMostRecentFocusOwner(aWindow);
- if (toFocus != null && toFocus != vetoedComponent && doRestoreFocus(toFocus, vetoedComponent, false)) {
- return true;
- } else if (clearOnFailure) {
+ if (toFocus != null && toFocus != vetoedComponent) {
+ Component heavyweight = getHeavyweight(aWindow);
+ if (heavyweight != null) {
+ setNativeFocusOwner(heavyweight);
+ Toolkit.getEventQueue().createSecondaryLoop(
+ () -> getGlobalFocusedWindow() != aWindow, null, 50)
+ .enter();
+ }
+ if (getGlobalFocusedWindow() == aWindow &&
+ doRestoreFocus(toFocus, vetoedComponent, false)) {
+ return true;
+ }
+ }
+ if (clearOnFailure) {
clearGlobalFocusOwnerPriv();
return true;
} else {