CardLayout get the selected card's name
问题 How can I get the string identifier of the selected panel in card layout. 回答1: The CardLayout does not know what the currently selected panel is. You should keep this in memory yourself, when calling the show() method. 回答2: The CardLayout does not allow you to do this. However, you should be able to access the top panel of the CardLayout. So a little work around is to give each added panel a name, equal to the string identifier. That way you can get the top card, and get it's name. This is