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
3037 return true;
3038 }
3039 return (wto != wfrom);
3040 }
3041
3042 private static boolean isTemporary(Component to, Component from) {
3043 Window wto = SunToolkit.getContainingWindow(to);
3044 Window wfrom = SunToolkit.getContainingWindow(from);
3045 if (wto == null && wfrom == null) {
3046 return false;
3047 }
3048 if (wto == null) {
3049 return true;
3050 }
3051 if (wfrom == null) {
3052 return false;
3053 }
3054 return (wto != wfrom);
3055 }
3056
3057 @SuppressWarnings("deprecation")
3058 static Component getHeavyweight(Component comp) {
3059 if (comp == null || comp.getPeer() == null) {
3060 return null;
3061 } else if (comp.getPeer() instanceof LightweightPeer) {
3062 return comp.getNativeContainer();
3063 } else {
3064 return comp;
3065 }
3066 }
3067
3068 static Field proxyActive;
3069 // Accessor to private field isProxyActive of KeyEvent
3070 private static boolean isProxyActiveImpl(KeyEvent e) {
3071 if (proxyActive == null) {
3072 proxyActive = AccessController.doPrivileged(new PrivilegedAction<Field>() {
3073 public Field run() {
3074 Field field = null;
3075 try {
3076 field = KeyEvent.class.getDeclaredField("isProxyActive");
3077 if (field != null) {
3078 field.setAccessible(true);
3079 }
3080 } catch (NoSuchFieldException nsf) {
3081 assert(false);
|
1 /*
2 * Copyright (c) 2000, 2015, 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
3037 return true;
3038 }
3039 return (wto != wfrom);
3040 }
3041
3042 private static boolean isTemporary(Component to, Component from) {
3043 Window wto = SunToolkit.getContainingWindow(to);
3044 Window wfrom = SunToolkit.getContainingWindow(from);
3045 if (wto == null && wfrom == null) {
3046 return false;
3047 }
3048 if (wto == null) {
3049 return true;
3050 }
3051 if (wfrom == null) {
3052 return false;
3053 }
3054 return (wto != wfrom);
3055 }
3056
3057 static Component getHeavyweight(Component comp) {
3058 if (comp == null || comp.peer == null) {
3059 return null;
3060 } else if (comp.peer instanceof LightweightPeer) {
3061 return comp.getNativeContainer();
3062 } else {
3063 return comp;
3064 }
3065 }
3066
3067 static Field proxyActive;
3068 // Accessor to private field isProxyActive of KeyEvent
3069 private static boolean isProxyActiveImpl(KeyEvent e) {
3070 if (proxyActive == null) {
3071 proxyActive = AccessController.doPrivileged(new PrivilegedAction<Field>() {
3072 public Field run() {
3073 Field field = null;
3074 try {
3075 field = KeyEvent.class.getDeclaredField("isProxyActive");
3076 if (field != null) {
3077 field.setAccessible(true);
3078 }
3079 } catch (NoSuchFieldException nsf) {
3080 assert(false);
|