サンプルコード
import java.awt.* import javax.swing.* import groovy.swing.* sb = new SwingBuilder() sb.edt { frame( title: "example - images in Combobox", show: true, resizable: true, size: [200, 200], defaultCloseOperation: WindowConstants.EXIT_ON_CLOSE ){ def options = [ imageIcon(file:"e:/icons/home.png"), imageIcon(file:"e:/icons/plane.png"), imageIcon(file:"e:/icons/mobile2.png") ] 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.2.2, JDK 1.7 update55
0 件のコメント:
コメントを投稿