boolean (Component c) { if (c.isOpaque()) return true; Container parent = c.getParent(); // do not allow non-opaque scroll bars, because default layout does not support them return parent instanceof JScrollPane && parent.getLayout() instanceof ScrollPaneLayout.UIResource; }