I’ve been looking through the documentation for the Swing CardLayout and there doesn’t appear to be any way to determine which card is currently showing baked in to the class. Yet there must be a way to ask the layout which card it is currently showing, right?
Due to project constraints, I can’t simply extend it and add this functionality to a sub-class, so if there isn’t such a function does that mean I’m stuck tracking the component’s state external to the component (yuck!), or is there some other option buried somewhere deep in Swing?
According to the How to Use CardLayout tutorial,Try,
where
foois theJPanelinstance usingCardLayout.Reference: