2012-03-13 4 views
1

私はモデルグリフォンブール代入バグ?

@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') 
    } 
} 

が、その常に有効になって、doesntの問題のチェックボックスであれば、次のコード

を持っていますが選択されているか否かを判定する。

system.out.println("${model.readOnly}") 

truefalse正しくが、その常にtrue

音符に設定されたフレームにいくつかの理由のために示しています。その常にtrue

として常に真、または if "${model.readOnly}" == trueまたは if ("${model.readOnly}")仕事に設定します boolean a = "${model.readOnly}"も割り当てを

aなどのフレーム内のサイズも設定してください。

does not workどちらか

答えて

2

(a)テキスト領域は、設定するだけでなく、バ​​インドする必要があります。書かれているように、それは値を一度だけ読み取るでしょう。

t1 = textArea(text: part3 , editable: bind (source: model, sourceProperty:'readOnly') ,columns:50) 

(b)もう1つ、パックアシストサイズを組み合わせたものは一般に動作しません。サイズを宣言すると、宣言からpack:trueを削除します。