01: /*
02: * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25: package sun.awt;
26:
27: import java.awt.Component;
28: import java.awt.KeyboardFocusManager;
29: import java.awt.Window;
30:
31: import java.awt.peer.KeyboardFocusManagerPeer;
32:
33: import java.lang.reflect.InvocationTargetException;
34: import java.lang.reflect.Method;
35:
36: public class KeyboardFocusManagerPeerImpl implements
37: KeyboardFocusManagerPeer {
38: static native Window getNativeFocusedWindow();
39:
40: static native Component getNativeFocusOwner();
41:
42: static native void clearNativeGlobalFocusOwner(Window activeWindow);
43:
44: KeyboardFocusManagerPeerImpl(KeyboardFocusManager manager) {
45: }
46:
47: public Window getCurrentFocusedWindow() {
48: return getNativeFocusedWindow();
49: }
50:
51: public void setCurrentFocusOwner(Component comp) {
52: }
53:
54: public Component getCurrentFocusOwner() {
55: return getNativeFocusOwner();
56: }
57:
58: public void clearGlobalFocusOwner(Window activeWindow) {
59: clearNativeGlobalFocusOwner(activeWindow);
60: }
61:
62: static Method m_removeLastFocusRequest = null;
63:
64: public static void removeLastFocusRequest(Component heavyweight) {
65: try {
66: if (m_removeLastFocusRequest == null) {
67: m_removeLastFocusRequest = SunToolkit.getMethod(
68: KeyboardFocusManager.class,
69: "removeLastFocusRequest",
70: new Class[] { Component.class });
71: }
72: m_removeLastFocusRequest.invoke(null,
73: new Object[] { heavyweight });
74: } catch (InvocationTargetException ite) {
75: ite.printStackTrace();
76: } catch (IllegalAccessException ex) {
77: ex.printStackTrace();
78: }
79: }
80: }
|