findLifecycleOwner

fun Component.findLifecycleOwner(): LifecycleOwner?

Finds the LifecycleOwner of the composition root this component stands under, by walking the Swing component tree and reading the LIFECYCLE_OWNER_KEY client property off each JComponent. It answers null where nothing on the way up carries one - for a component in no window, and for a top-level window's content pane, whose ancestors end at a java.awt.Window that is no JComponent.

The walk is self-first, as findParentCompositionContext is: a component that already carries a live root's owner answers with that owner rather than skipping to the one above it, so a second root mounted on the same component joins the lifecycle of the first instead of minting a rival for it.