- text:メニュー表示文字列
- mnemonic:ニーモニック
- selected:選択状態
import java.awt.* import javax.swing.* import groovy.swing.* import groovy.beans.* @Bindable class MyModel { boolean flag1 } def mymodel = new MyModel() sb = new SwingBuilder() sb.edt { frame( title: "checkbox menu item example", show: true, resizable: true, size: [300, 200], defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE ){ menuBar(){ menu(text:"View", mnemonic: "V"){ checkBoxMenuItem(id:"detailView", text:"detail view", mnemonic: "D", // 双方向バインド selected:bind(targetProperty:'flag1', target:mymodel, mutual:true) ) menuItem(text: "reset", actionPerformed:{mymodel.flag1 = false}) } detailView.selected = true } button(text: "OK", constraints: BorderLayout.SOUTH, actionPerformed:{ println mymodel.flag1 } ) } }実行時画面
動作環境
groovy 2.2.2, JDK 1.7 update55
0 件のコメント:
コメントを投稿