37 import java.awt.peer.ComponentPeer; |
37 import java.awt.peer.ComponentPeer; |
38 |
38 |
39 import java.lang.reflect.InvocationTargetException; |
39 import java.lang.reflect.InvocationTargetException; |
40 import java.lang.reflect.Method; |
40 import java.lang.reflect.Method; |
41 |
41 |
42 import java.util.logging.Level; |
42 import sun.util.logging.PlatformLogger; |
43 import java.util.logging.Logger; |
|
44 |
43 |
45 public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer { |
44 public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer { |
46 |
45 |
47 private static final Logger focusLog = Logger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl"); |
46 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl"); |
48 |
47 |
49 private static AWTAccessor.KeyboardFocusManagerAccessor kfmAccessor = |
48 private static AWTAccessor.KeyboardFocusManagerAccessor kfmAccessor = |
50 AWTAccessor.getKeyboardFocusManagerAccessor(); |
49 AWTAccessor.getKeyboardFocusManagerAccessor(); |
51 |
50 |
52 // The constants are copied from java.awt.KeyboardFocusManager |
51 // The constants are copied from java.awt.KeyboardFocusManager |
62 |
61 |
63 @Override |
62 @Override |
64 public void clearGlobalFocusOwner(Window activeWindow) { |
63 public void clearGlobalFocusOwner(Window activeWindow) { |
65 if (activeWindow != null) { |
64 if (activeWindow != null) { |
66 Component focusOwner = activeWindow.getFocusOwner(); |
65 Component focusOwner = activeWindow.getFocusOwner(); |
67 if (focusLog.isLoggable(Level.FINE)) focusLog.fine("Clearing global focus owner " + focusOwner); |
66 if (focusLog.isLoggable(PlatformLogger.FINE)) |
|
67 focusLog.fine("Clearing global focus owner " + focusOwner); |
68 if (focusOwner != null) { |
68 if (focusOwner != null) { |
69 FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null, |
69 FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null, |
70 CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER); |
70 CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER); |
71 SunToolkit.postPriorityEvent(fl); |
71 SunToolkit.postPriorityEvent(fl); |
72 } |
72 } |
128 } |
128 } |
129 if (currentOwner != null) { |
129 if (currentOwner != null) { |
130 FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, |
130 FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST, |
131 false, lightweightChild, cause); |
131 false, lightweightChild, cause); |
132 |
132 |
133 if (focusLog.isLoggable(Level.FINER)) focusLog.finer("Posting focus event: " + fl); |
133 if (focusLog.isLoggable(PlatformLogger.FINER)) |
|
134 focusLog.finer("Posting focus event: " + fl); |
134 SunToolkit.postPriorityEvent(fl); |
135 SunToolkit.postPriorityEvent(fl); |
135 } |
136 } |
136 |
137 |
137 FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, |
138 FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, |
138 false, currentOwner, cause); |
139 false, currentOwner, cause); |
139 |
140 |
140 if (focusLog.isLoggable(Level.FINER)) focusLog.finer("Posting focus event: " + fg); |
141 if (focusLog.isLoggable(PlatformLogger.FINER)) |
|
142 focusLog.finer("Posting focus event: " + fg); |
141 SunToolkit.postPriorityEvent(fg); |
143 SunToolkit.postPriorityEvent(fg); |
142 return true; |
144 return true; |
143 } |
145 } |
144 |
146 |
145 // WARNING: Don't call it on the Toolkit thread. |
147 // WARNING: Don't call it on the Toolkit thread. |