I have a JScrollPane containing a JPanel. I fill this JPanel with many buttons.
Is there any possibility to get the currently shown buttons?
I know I can access the children of a JPanel via jpanel.getComponents() but those are all components in this pane; I want only the ones that are currently on screen.
I assume that this container is already visible on the screen, then I suggest
1) to extract JViewPort from JScrollPane,
2) addChangeListener to
JViewPort3) each visible
JComponent(s)returns Rectangle4) and Rectangle#intersects returns
Booleanvalue if isJComponent(s)visible or not inJViewPort