code: private JComponent getEffectiveClippingAncestor() {
          JComponent clippingComponent = clippingAncestor;
  
          if ((clippingComponent == null) && (decoratedComponent != null)) {
              // No specific clipping ancestor specified by the programmer, so try to find one
  
              // Keep a reference to the best alternative candidate if no other proper ancestor can be found
              Container lastNonNullParent = decoratedComponent;
  
              // Look for the first viewport or layered pane in the component hierarchy tree
              Container parent = decoratedComponent.getParent();
              while ((parent != null) && (clippingComponent == null)) {
                  lastNonNullParent = parent;
                  if ((parent instanceof JViewport) || (parent instanceof JLayeredPane)) {
                      clippingComponent = (JComponent) parent;
                  }
                  parent = parent.getParent();
              }
  
              if (clippingComponent == null) {
                  // This may be a normal case depending on the application logic to hide a panel (tabbed pane like)
                  if (lastNonNullParent instanceof JComponent) {
                      clippingComponent = (JComponent) lastNonNullParent;
                  }
              }
          }
  
          return clippingComponent;
      }
docs: Gets the effective clipping ancestor.
  <p>
  If no custom clipping ancestor is set, the parent container of the decorated component will be returned.
  
  @return Effective clipping ancestor.