1
我在模型Griffon布爾賦值錯誤?
@Bindable boolean readOnly
下面的代碼
視圖
checkBox(text: 'Read Only', constraints:'wrap',selected:bind(target: model, targetProperty:'readOnly'))
控制器
new groovy.swing.SwingBuilder().frame(title:'File opened',pack:true,show:true){
panel(layout: new MigLayout('fill'), border: titledBorder('Content')){
separator(constraints:"cell 0 1")
textArea(text: part1 , editable: false)
separator(constraints:"cell 0 2")
textArea(text: part2 , editable: false)
separator(constraints:"cell 0 1")
t1 = textArea(text: part3 , editable: "${model.readOnly}",columns:50)
separator(constraints:"cell 0 2")
t2 = textArea(text: part4 , editable: "${model.readOnly}")
separator(constraints:"cell 0 3")
button('Save!', actionPerformed: save, constraints: 'span 5, bottom, right')
}
}
但其始終處於啓用狀態,犯規如果複選框事是否被選中。
system.out.println("${model.readOnly}")
顯示true
和false
正常,但在框架上的一些原因,它總是被設置爲true
注:也分配boolean a = "${model.readOnly}"
設置一個總是爲真,或if "${model.readOnly}" == true
或if ("${model.readOnly}")
工作作爲它總是true
哦,還設置框架中的大小,如
new groovy.swing.SwingBuilder().frame(title:'File opened',pack:true,show:true, size : [640,480]){
不工作