if (c.getParent() == jPanel)
The call is recursive if you don't need a direct parent-child relationship (which probably takes place in a well-designed panel).
... although in a well-designed panel, it is very doubtful why you need to know if the component is contained in the panel.
source
share