import java.awt.* import javax.swing.* import groovy.swing.* sb = new SwingBuilder() sb.edt { frame( title: "radio button example", show: true, resizable: true, pack: true, defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE, layout:new FlowLayout() ){ def bg = buttonGroup(id:"bg") radioButton(id:"rb1", text:"option1", selected:true, buttonGroup:bg) radioButton(id:"rb2", text:"option2", buttonGroup:bg) radioButton(id:"rb3", text:"option3", buttonGroup:bg) button(text:"OK", constraints: BorderLayout.SOUTH, actionPerformed: { sb.optionPane( message:"rb1=${sb.rb1.selected}, rb2=${sb.rb2.selected}, rb3=${sb.rb3.selected}", messageType:JOptionPane.INFORMATION_MESSAGE) .createDialog("radiobutton").visible = true } ) } }実行時画面
動作環境
groovy 2.2.2, JDK 1.7 update55
0 件のコメント:
コメントを投稿