import java.awt.* import javax.swing.* import groovy.swing.* sb = new SwingBuilder() sb.edt { frame( title: "Combobox example", show: true, resizable: true, pack: true, defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE ){ def options = ["example option1", "example option2", "example option3"] comboBox(id:"cb1", items: options, constraints: BorderLayout.NORTH ) button(text:"OK", constraints: BorderLayout.SOUTH, actionPerformed: { sb.optionPane( message:"combobox1=${sb.cb1.selectedItem}, index=${sb.cb1.selectedIndex}", messageType:JOptionPane.INFORMATION_MESSAGE) .createDialog("combobox").visible = true } ) } }実行時画面
動作環境
groovy 2.1.7, JDK 1.7
0 件のコメント:
コメントを投稿