private void detachFromHierarchyOf(Container container) { container.removeContainerListener(this); Component[] components = container.getComponents(); for (int i = 0; i < components.length; i++) { detachFrom(components[i]); // Will callback recursively any nested JPanels } }
public void uninstallRecursively(Component c) { uninstall(c); if (c instanceof Container) { Container cont = (Container) c; cont.removeContainerListener(containerListener); uninstallRecursively(cont); } }
private void componentRemoved(Component comp) { comp.removeKeyListener(keyHandler); if (comp instanceof Container) { Container cont = (Container) comp; cont.removeContainerListener(this); Component[] comps = cont.getComponents(); for (Component comp1 : comps) componentRemoved(comp1); } }
/** * This method removes the {@link KeyListener} from all removed components. This is done * recursively. * * @param c The {@link Component} that is removed. */ private void removeKeyAndContainerListenerRecursively(final Component c) { c.removeKeyListener(this); if (c instanceof Container) { final Container cont = (Container) c; cont.removeContainerListener(this); final Component[] children = cont.getComponents(); for (int i = 0; i < children.length; i++) { removeKeyAndContainerListenerRecursively(children[i]); } } }
void uninstallListeners(Component component) { for (ComponentListener listener : componentListeners) component.removeComponentListener(listener); for (KeyListener listener : keyListeners) component.removeKeyListener(listener); for (MouseListener listener : mouseListeners) component.removeMouseListener(listener); for (MouseMotionListener listener : mouseMotionListeners) component.removeMouseMotionListener(listener); if (component instanceof Container) { Container container = (Container) component; container.removeContainerListener(containerListener); for (int iComp = container.getComponentCount(); iComp-- != 0; ) { uninstallListeners(container.getComponent(iComp)); } } }