protected Component getRoot ( Component comp ) { for ( Component c = comp ; c != null ; c = c . getParent ( ) ) { boolean hidden = ! c . isDisplayable ( ) ; // on the mac, the JRootPane is invalidated before it is visible and is never again // invalidated or repainted, so we punt and allow all invisible components to be // invalidated and revalidated if ( ! RunAnywhere . isMacOS ( ) ) { hidden |= ! c . isVisible ( ) ; } if ( hidden ) { return null ; } if ( c instanceof Window || c instanceof Applet ) { return c ; } } return null ; }
Returns the root component for the supplied component or null if it is not part of a rooted hierarchy or if any parent along the way is found to be hidden or without a peer .