code: private Integer getDecoratedComponentLayerInLayeredPane(JLayeredPane layeredPane) {
          Container ancestorInLayer = decoratedComponent;
          while (!layeredPane.equals(ancestorInLayer.getParent())) {
              ancestorInLayer = ancestorInLayer.getParent();
          }
  
          return (layeredPane.getLayer(ancestorInLayer) + DECORATION_LAYER_OFFSET);
      }
docs: Retrieves the layer index of the decorated component in the layered pane of the window.
  
  @param layeredPane Layered pane of the window.
  
  @return Index of the decorated component in the layered pane.