src/share/classes/java/awt/DefaultKeyboardFocusManager.java

Print this page




 542                 }
 543 
 544                 if (!(newFocusOwner.isFocusable() && newFocusOwner.isShowing() &&
 545                     // Refuse focus on a disabled component if the focus event
 546                     // isn't of UNKNOWN reason (i.e. not a result of a direct request
 547                     // but traversal, activation or system generated).
 548                     (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
 549                 {
 550                     // we should not accept focus on such component, so reject it.
 551                     dequeueKeyEvents(-1, newFocusOwner);
 552                     if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
 553                         // If FOCUS_GAINED is for a disposed component (however
 554                         // it shouldn't happen) its toplevel parent is null. In this
 555                         // case we have to try to restore focus in the current focused
 556                         // window (for the details: 6607170).
 557                         if (newFocusedWindow == null) {
 558                             restoreFocus(fe, currentFocusedWindow);
 559                         } else {
 560                             restoreFocus(fe, newFocusedWindow);
 561                         }

 562                     }
 563                     break;
 564                 }
 565 
 566                 setGlobalFocusOwner(newFocusOwner);
 567 
 568                 if (newFocusOwner != getGlobalFocusOwner()) {
 569                     // Focus change was rejected. Will happen if
 570                     // newFocusOwner is not focus traversable.
 571                     dequeueKeyEvents(-1, newFocusOwner);
 572                     if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
 573                         restoreFocus(fe, (Window)newFocusedWindow);
 574                     }
 575                     break;
 576                 }
 577 
 578                 if (!fe.isTemporary()) {
 579                     setGlobalPermanentFocusOwner(newFocusOwner);
 580 
 581                     if (newFocusOwner != getGlobalPermanentFocusOwner()) {




 542                 }
 543 
 544                 if (!(newFocusOwner.isFocusable() && newFocusOwner.isShowing() &&
 545                     // Refuse focus on a disabled component if the focus event
 546                     // isn't of UNKNOWN reason (i.e. not a result of a direct request
 547                     // but traversal, activation or system generated).
 548                     (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
 549                 {
 550                     // we should not accept focus on such component, so reject it.
 551                     dequeueKeyEvents(-1, newFocusOwner);
 552                     if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
 553                         // If FOCUS_GAINED is for a disposed component (however
 554                         // it shouldn't happen) its toplevel parent is null. In this
 555                         // case we have to try to restore focus in the current focused
 556                         // window (for the details: 6607170).
 557                         if (newFocusedWindow == null) {
 558                             restoreFocus(fe, currentFocusedWindow);
 559                         } else {
 560                             restoreFocus(fe, newFocusedWindow);
 561                         }                        
 562                         setMostRecentFocusOwner(newFocusedWindow, null); // see: 8013773
 563                     }
 564                     break;
 565                 }
 566 
 567                 setGlobalFocusOwner(newFocusOwner);
 568 
 569                 if (newFocusOwner != getGlobalFocusOwner()) {
 570                     // Focus change was rejected. Will happen if
 571                     // newFocusOwner is not focus traversable.
 572                     dequeueKeyEvents(-1, newFocusOwner);
 573                     if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
 574                         restoreFocus(fe, (Window)newFocusedWindow);
 575                     }
 576                     break;
 577                 }
 578 
 579                 if (!fe.isTemporary()) {
 580                     setGlobalPermanentFocusOwner(newFocusOwner);
 581 
 582                     if (newFocusOwner != getGlobalPermanentFocusOwner()) {