私は Groovy Swingbuilder を使用しており、最初のパネルが構築された後にラジオ ボタン - ボタングループを動的に埋めたいと考えています。例: いくつかのオプションがあるパネルがあります。選択したオプションに基づいて、ボタン グループに一連のラジオ ボタンを配置する必要があります。無線オプションは、オプションごとに異なります。
私のパネルは次のようになります。
panel(id:"chooseClass", visible:true, layout: new BL()){
vbox(constraints: BL.CENTER){
label("Player Statistics", horizontalAlignment: 0)
label(id: 'raceLabel', text: raceLabelText, horizontalAlignment: 0)
label(id: 'statLabel', text: statLabelText, horizontalAlignment: 0)
panel(id:'classGroupPanel', layout: new GridLayout(1,9)){
myButtonGroup = buttonGroup(id:'classGroup')
}
}
}
その後、私のコードの後半には、このメソッドがあります:
def void setClassGroup(){
def classButtons = plyGen.getAvailibleClass()
// this is one way I've tried it
gPane.edt{panel(id:'classGroupPanel', layout: new GridLayout(1,9)){
buttonGroup(id:'classGroup').with{ group ->
classButtonGroup.each{ radioButton(id: '${it.name}', CreateRadio("${it.name}"), mnemonic:"${it.mnenomic}", buttonGroup: group)}}
}
}
// and this is another way I've tried it
gPane.doOutside {
this.classGroupPanel{
buttonGroup(id:'classGroup').with{group ->
classButtons.each{ gPane.radioButton(id: '${it.name}', CreateRadio("${it.name}"), mnemonic:"${it.mnenomic}", buttonGroup: myButtonGroup) }
}
}
}
}
これらの試行は両方ともエラーなしでコンパイルおよび実行されますが、ラジオ ボタンのリストを取得できません。私は、swingbuilder のドキュメントがもっとあればいいのにと思います。