我想要一种减少java GUI代码的方法

时间:2014-02-02 08:47:52

标签: java

假设我想设计带有30个无线电盒的Java GUI框架。有没有办法添加它们而不写多行代码可能约60行?

2 个答案:

答案 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);
}