/** * @param component component * @return whether the component in Swing tree or not. This method is more weak then {@link * Component#isShowing() } */ private boolean isInTree(final Component component) { if (component instanceof Window) { return component.isShowing(); } else { Window windowAncestor = SwingUtilities.getWindowAncestor(component); return windowAncestor != null && windowAncestor.isShowing(); } }