src/share/classes/java/awt/Component.java

Print this page

        

*** 9064,9073 **** --- 9064,9082 ---- private volatile transient int propertyListenersCount = 0; protected ComponentListener accessibleAWTComponentHandler = null; protected FocusListener accessibleAWTFocusHandler = null; + // accessibleAWTFocusHandler can be set either from + // JComponent.AccessibleJComponent.addPropertyChangeListener or from this + // object's addPropertyChangeListener the first time that method is called + // if accessibleAWTFocusHandler is null at the time of the call. In the + // former case Component.addFocusListener has already been called so it + // should not be called again in this object's addPropertyChangeListener. + // Also, removeFocusListener should only be called if this boolean is set. + boolean focusHandlerSetFromComponent = false; + /** * Fire PropertyChange listener, if one is registered, * when shown/hidden.. * @since 1.3 */
*** 9127,9142 **** --- 9136,9154 ---- public void addPropertyChangeListener(PropertyChangeListener listener) { if (accessibleAWTComponentHandler == null) { accessibleAWTComponentHandler = new AccessibleAWTComponentHandler(); } if (accessibleAWTFocusHandler == null) { + focusHandlerSetFromComponent = true; accessibleAWTFocusHandler = new AccessibleAWTFocusHandler(); } if (propertyListenersCount++ == 0) { Component.this.addComponentListener(accessibleAWTComponentHandler); + if (focusHandlerSetFromComponent) { Component.this.addFocusListener(accessibleAWTFocusHandler); } + } super.addPropertyChangeListener(listener); } /** * Remove a PropertyChangeListener from the listener list.
*** 9146,9157 **** --- 9158,9171 ---- * @param listener The PropertyChangeListener to be removed */ public void removePropertyChangeListener(PropertyChangeListener listener) { if (--propertyListenersCount == 0) { Component.this.removeComponentListener(accessibleAWTComponentHandler); + if (focusHandlerSetFromComponent) { Component.this.removeFocusListener(accessibleAWTFocusHandler); } + } super.removePropertyChangeListener(listener); } // AccessibleContext methods //