I have a JScrollpane which contains a big JPanel and the JPanel it’s self contains 3 JPanels. each of those 3 JPanels has the same size as the JScrollpane. the user can not scroll. he can clicks on a button and sees the next or previous JPanel (only 1 panel can bee seen at a moment and he can not see a part of one panel and part of other…).
How can I understand which panel is being seen right now?
Assuming the setup as outlined in my comment to your question, the basic approach is to compare the parent’s (the component that contains the 3 panels) visibleRect with its children’s bounds. Something like:
As an aside: to fine-tune scrolling behaviour you might consider a custom panel which implements Scrollable, something like: