void (final ContainerEvent e) { Component removedChild = e.getChild(); if (getNearestFocusableComponent() != null && SwingUtilities.isDescendingFrom(getNearestFocusableComponent(), removedChild)) { setNearestFocusableComponent(null); } if (getFocusedComponent() != null && SwingUtilities.isDescendingFrom(getFocusedComponent(), removedChild)) { setNearestFocusableComponent(e.getContainer()); } deinstall(removedChild, e); }