United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4467840 : Please generate a PropertyChange when KeyboardFocusManager changes

Details
Type:
Enhancement
Submit Date:
2001-06-08
Status:
Resolved
Updated Date:
2003-05-25
Project Name:
JDK
Resolved Date:
2003-05-25
Component:
client-libs
OS:
solaris_7
Sub-Component:
java.awt
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

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
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

======================================================================
                                     
2003-03-20
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>


======================================================================
                                     
2004-08-24
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b08


                                     
2004-08-24



Hardware and Software, Engineered to Work Together