获取对当前显示卡的引用

Get Reference to Currently Displayed Card

假设我有一个名为 cardsJPanel,它的布局类型为 CardLayout。布局中的每张卡片也是classJPanel。如何获取对当前显示在布局中的 JPanel 的引用?

谢谢。

How do I get a reference to the JPanel that’s currently being displayed in the layout?

据我所知,API 中没有任何内容允许您执行此操作。所以,我扩展了 CardLayout 以提供此信息。

查看 Card Layout Focus 以了解我的实现,它允许您获取此信息等。