static L stackElementsShowing(final DynamicStack stack) { ret swing(func -> L { new L l; if (!stack.isShowing()) ret l; JScrollPane sp = enclosingScrollPane(stack); if (sp == null) ret l; JViewport vp = sp.getViewport(); Rect vpRect = toRect(vp.getBounds()); for (Component c : stack.components()) if (rectsIntersect(vpRect, boundsInParent(c, vp))) l.add(c); ret l; }); }