Sets the current KeyboardFocusManager
instance
for the calling thread's context. If null
is
specified, then the current KeyboardFocusManager
is replaced with a new instance of
DefaultKeyboardFocusManager
.
If a SecurityManager
is installed,
the calling thread must be granted the AWTPermission
"replaceKeyboardFocusManager" in order to replace the
the current KeyboardFocusManager
.
If this permission is not granted,
this method will throw a SecurityException
,
and the current KeyboardFocusManager
will be unchanged.
// Note: This method is not backward-compatible with 1.3 and earlier
// releases. It now throws a SecurityException in an applet, whereas
// in previous releases, it did not. This issue was discussed at
// length, and ultimately approved by Hans.
KeyboardFocusManager toSet =
(aFocusManager instanceof DelegatingDefaultFocusManager)
? ((DelegatingDefaultFocusManager)aFocusManager).getDelegate()
: aFocusManager;
KeyboardFocusManager.setCurrentKeyboardFocusManager(toSet);