How can I determine which card is curently being displayed in a CardLayout?

Scott Stanchfield

The displayed component will be the only one in the container that is visible.

You can walk through the components in the container and check which one is visible.

For example, to determine if you're on the first or last component (perhaps to disable "previous" and "next" buttons) you could do something like the following (assuming p is the panel with the CardLayout)

boolean firstShowing = 

boolean lastShowing = 
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact