groovy 简单的弹出菜单popupmenu程序

时间:2014-05-01 00:20:13   收藏:0   阅读:342
 1 import groovy.swing.* 
 2 import javax.swing.* 
 3 import java.awt.*
 4 
 5 def swing = new SwingBuilder()
 6 swing.frame(title:"hello",show:true)
 7 {
 8   panel()
 9 {
10   def mm=swing.textField(text:"bcxhdbhd")
11   mm.mousePressed={e->
12 def popupMenu=swing.popupMenu()
13 {
14   menuItem(text:"bhdfyhefyh")
15 }
16   popupMenu.show(e.getComponent(),e.getX(),e.getY())//这里的e.getComponent()换成mm也一样
17   println("jjjj")
18   mm.setText("kkkkkk")
19 }
20 
21 }
22 }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!