1 /*
2 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
561 // it shouldn't happen) its toplevel parent is null. In this
562 // case we have to try to restore focus in the current focused
563 // window (for the details: 6607170).
564 if (newFocusedWindow == null) {
565 restoreFocus(fe, currentFocusedWindow);
566 } else {
567 restoreFocus(fe, newFocusedWindow);
568 }
569 setMostRecentFocusOwner(newFocusedWindow, null); // see: 8013773
570 }
571 break;
572 }
573
574 setGlobalFocusOwner(newFocusOwner);
575
576 if (newFocusOwner != getGlobalFocusOwner()) {
577 // Focus change was rejected. Will happen if
578 // newFocusOwner is not focus traversable.
579 dequeueKeyEvents(-1, newFocusOwner);
580 if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
581 restoreFocus(fe, (Window)newFocusedWindow);
582 }
583 break;
584 }
585
586 if (!fe.isTemporary()) {
587 setGlobalPermanentFocusOwner(newFocusOwner);
588
589 if (newFocusOwner != getGlobalPermanentFocusOwner()) {
590 // Focus change was rejected. Unlikely, but possible.
591 dequeueKeyEvents(-1, newFocusOwner);
592 if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
593 restoreFocus(fe, (Window)newFocusedWindow);
594 }
595 break;
596 }
597 }
598
599 setNativeFocusOwner(getHeavyweight(newFocusOwner));
600
601 Component realOppositeComponent = this.realOppositeComponentWR.get();
602 if (realOppositeComponent != null &&
603 realOppositeComponent != fe.getOppositeComponent()) {
604 fe = new CausedFocusEvent(newFocusOwner,
605 FocusEvent.FOCUS_GAINED,
606 fe.isTemporary(),
607 realOppositeComponent, cause);
608 ((AWTEvent) fe).isPosted = true;
609 }
610 return typeAheadAssertions(newFocusOwner, fe);
611 }
612
613 case FocusEvent.FOCUS_LOST: {
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
561 // it shouldn't happen) its toplevel parent is null. In this
562 // case we have to try to restore focus in the current focused
563 // window (for the details: 6607170).
564 if (newFocusedWindow == null) {
565 restoreFocus(fe, currentFocusedWindow);
566 } else {
567 restoreFocus(fe, newFocusedWindow);
568 }
569 setMostRecentFocusOwner(newFocusedWindow, null); // see: 8013773
570 }
571 break;
572 }
573
574 setGlobalFocusOwner(newFocusOwner);
575
576 if (newFocusOwner != getGlobalFocusOwner()) {
577 // Focus change was rejected. Will happen if
578 // newFocusOwner is not focus traversable.
579 dequeueKeyEvents(-1, newFocusOwner);
580 if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
581 restoreFocus(fe, newFocusedWindow);
582 }
583 break;
584 }
585
586 if (!fe.isTemporary()) {
587 setGlobalPermanentFocusOwner(newFocusOwner);
588
589 if (newFocusOwner != getGlobalPermanentFocusOwner()) {
590 // Focus change was rejected. Unlikely, but possible.
591 dequeueKeyEvents(-1, newFocusOwner);
592 if (KeyboardFocusManager.isAutoFocusTransferEnabled()) {
593 restoreFocus(fe, newFocusedWindow);
594 }
595 break;
596 }
597 }
598
599 setNativeFocusOwner(getHeavyweight(newFocusOwner));
600
601 Component realOppositeComponent = this.realOppositeComponentWR.get();
602 if (realOppositeComponent != null &&
603 realOppositeComponent != fe.getOppositeComponent()) {
604 fe = new CausedFocusEvent(newFocusOwner,
605 FocusEvent.FOCUS_GAINED,
606 fe.isTemporary(),
607 realOppositeComponent, cause);
608 ((AWTEvent) fe).isPosted = true;
609 }
610 return typeAheadAssertions(newFocusOwner, fe);
611 }
612
613 case FocusEvent.FOCUS_LOST: {
|