[英]Change label many JButtons in Java Swing GUI
My problem is I want to change many JButton's labels (may be over 10 or more buttons btw).我的问题是我想更改许多 JButton 的标签(顺便说一句,可能超过 10 个或更多按钮)。 Is there anyway to use loop to do that?.
反正有没有使用循环来做到这一点? For example: I have 10 buttons is numbered 0 - 9. I want to change the label of buttons from 11 - 20 (Not changing each property one by one of course:) ).
例如:我有 10 个按钮,编号为 0 - 9。我想将按钮的 label 从 11 - 20 更改(当然不是逐个更改每个属性:))。 Thank you and sorry for my bad English.
谢谢你,对不起我的英语不好。
The answer is put buttons into an array, create a new array to store numbers.答案是将按钮放入数组中,创建一个新数组来存储数字。 Use loop to add each number to each button.
使用循环将每个数字添加到每个按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.