void (Component component) { while(component!=null){ component.removePropertyChangeListener(ANCESTOR_PROPERTY_NAME,this); // it prevent double registering component.addPropertyChangeListener(ANCESTOR_PROPERTY_NAME,this); component.removeComponentListener(this); // it prevent double registering component.addComponentListener(this); component=component.getParent(); } }