void (@NotNull Container container) { assert SwingUtilities.isEventDispatchThread(); AWTAccessor.getComponentAccessor().setParent(container, null); container.removeAll(); for (ComponentListener c : container.getComponentListeners()) container.removeComponentListener(c); for (FocusListener c : container.getFocusListeners()) container.removeFocusListener(c); for (HierarchyListener c : container.getHierarchyListeners()) container.removeHierarchyListener(c); for (HierarchyBoundsListener c : container.getHierarchyBoundsListeners()) container.removeHierarchyBoundsListener(c); for (KeyListener c : container.getKeyListeners()) container.removeKeyListener(c); for (MouseListener c : container.getMouseListeners()) container.removeMouseListener(c); for (MouseMotionListener c : container.getMouseMotionListeners()) container.removeMouseMotionListener(c); for (MouseWheelListener c : container.getMouseWheelListeners()) container.removeMouseWheelListener(c); for (InputMethodListener c : container.getInputMethodListeners()) container.removeInputMethodListener(c); for (PropertyChangeListener c : container.getPropertyChangeListeners()) container.removePropertyChangeListener(c); for (ContainerListener c : container.getContainerListeners()) container.removeContainerListener(c); }