首页 > 代码库 > groovy 简单的弹出菜单popupmenu程序

groovy 简单的弹出菜单popupmenu程序

 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 }

 

groovy 简单的弹出菜单popupmenu程序