假设我想设计带有30个无线电盒的Java GUI框架。有没有办法添加它们而不写多行代码可能约60行?
答案 0 :(得分:2)
for (int i=1; i <30; i++){
//radio check box adding code here
}
答案 1 :(得分:0)
Declare all radio button names in an array and do the iteration like following,
String[5] radioString = {"P","Q","R","S","T"}; //declare as much as you want
for(String radioName : radioString){
JRadioButton rectangular = new JRadioButton(radioName);
}