[英]How to Count Number of Cards in a CardLayout
I have a JPanel
which uses a CardLayout
to have a number of pages, and to make a progress bar that fills up as pages are defined, I would like to count the number of cards added to my CardLayout
. 我有一个
JPanel
,它使用CardLayout
来拥有许多页面,并创建一个进度条以在定义页面时填满,我想计算添加到CardLayout
的卡片数量。 Is there a way of counting cards programatically, or will I have to track the number of pages with a variable? 是否可以通过编程方式对卡进行计数,还是我必须使用变量来跟踪页数?
由于卡是JPanel
保留的唯一组件,因此getComponentCount()
实际上返回页面数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.