JDK-4467840 : Please generate a PropertyChange when KeyboardFocusManager changes
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2001-06-08
  • Updated: 2017-05-16
  • Resolved: 2003-05-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description
It would be nice if there was a way to be notified if the KeyboardFocusManager changed. Swing currently installs a handful of things necessary for proper keyboard navigation to work on the KFM. If the developer installs a KFM these will no longer work as Swing has no way to determine when the KFM has changed (short of checking on every KeyEvent or other yucky checks).

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b08
24-08-2004

SUGGESTED FIX Name: osR10079 Date: 03/21/2003 ###@###.###, March 21, 2003 ------- KeyboardFocusManager.java ------- *** /tmp/dcVaOGi Thu Mar 20 08:20:30 2003 --- KeyboardFocusManager.java Thu Mar 20 08:17:04 2003 *************** *** 164,189 **** * @throws SecurityException if the calling thread does not have permission * to replace the current KeyboardFocusManager */ ! public synchronized static void setCurrentKeyboardFocusManager( KeyboardFocusManager newManager) throws SecurityException { ! AppContext appcontext = AppContext.getAppContext(); ! if (newManager != null) { ! SecurityManager security = System.getSecurityManager(); ! if (security != null) { ! if (replaceKeyboardFocusManagerPermission == null) { ! replaceKeyboardFocusManagerPermission = ! new AWTPermission("replaceKeyboardFocusManager"); ! } ! security. ! checkPermission(replaceKeyboardFocusManagerPermission); ! } ! appcontext.put(KeyboardFocusManager.class, newManager); ! } else { ! appcontext.remove(KeyboardFocusManager.class); } } /** --- 164,207 ---- * @throws SecurityException if the calling thread does not have permission * to replace the current KeyboardFocusManager */ ! public static void setCurrentKeyboardFocusManager( KeyboardFocusManager newManager) throws SecurityException { ! SecurityManager security = System.getSecurityManager(); ! if (security != null) { ! if (replaceKeyboardFocusManagerPermission == null) { ! replaceKeyboardFocusManagerPermission = ! new AWTPermission("replaceKeyboardFocusManager"); ! } ! security. ! checkPermission(replaceKeyboardFocusManagerPermission); ! } ! KeyboardFocusManager oldManager = null; ! synchronized (KeyboardFocusManager.class) { ! AppContext appcontext = AppContext.getAppContext(); ! ! if (newManager != null) { ! oldManager = getCurrentKeyboardFocusManager(appcontext); ! ! appcontext.put(KeyboardFocusManager.class, newManager); ! } else { ! oldManager = getCurrentKeyboardFocusManager(appcontext); ! appcontext.remove(KeyboardFocusManager.class); ! } } + + if (oldManager != null) { + oldManager.firePropertyChange("managingFocus", + Boolean.TRUE, + Boolean.FALSE); + } + if (newManager != null) { + newManager.firePropertyChange("managingFocus", + Boolean.FALSE, + Boolean.TRUE); + } } /** *************** *** 1105,1110 **** --- 1123,1131 ---- * registered for all bound properties of this class, including the * following: * <ul> + * <li>whether the KeyboardFocusManager is currently managing focus + * for this application or applet's browser context + * ("managingFocus")</li> * <li>the focus owner ("focusOwner")</li> * <li>the permanent focus owner ("permanentFocusOwner")</li> * <li>the focused Window ("focusedWindow")</li> *************** *** 1187,1192 **** --- 1208,1216 ---- * property. The specified property may be user-defined, or one of the * following: * <ul> + * <li>whether the KeyboardFocusManager is currently managing focus + * for this application or applet's browser context + * ("managingFocus")</li> * <li>the focus owner ("focusOwner")</li> * <li>the permanent focus owner ("permanentFocusOwner")</li> * <li>the focused Window ("focusedWindow")</li> ======================================================================
24-08-2004

EVALUATION Name: osR10079 Date: 03/20/2003 to implement this rfe i suggest to add new bound property of keyboard focus manager, which will indicate when this manager become active (starts to managing focus owner) and when it's deactivated (changed to another manager). ###@###.### 2003-03-20 ======================================================================
20-03-2003