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 }
时间: 2024-10-10 23:22:37