static Rect boundsInParent(Component c, Class parentType) { ret boundsInParent(c, parentOfType(c, parentType)); } static Rect boundsInParent(Component _c, Component parent) { if (_c == null) null; ret swing(func -> Rect { if (_c == parent) ret Rect(0, 0, _c.getWidth(), _c.getHeight()); Rect r = toRect(_c.getBounds()); Component c = _c; while true { c = c.getParent(); if (c == null) null; if (c == parent) ret r; r = translateRect(r, c.getX(), c.getY()); } }); }