groovy 弹出菜单

import groovy.swing.* 
import javax.swing.* 
import java.awt.*

def swing = new SwingBuilder()
swing.frame(title:"hello",show:true){
  panel(){
      def mm=swing.textField(text:"bcxhdbhd")
      mm.mousePressed={e->
            def popupMenu=swing.popupMenu(){
             menuItem(text:"bhdfyhefyh")
            }
           popupMenu.show(e.getComponent(),e.getX(),e.getY())
            //这里的e.getComponent()换成mm也一样
          println("jjjj")
          mm.setText("kkkkkk")
        }

    }
}            

 

posted @ 2015-04-13 23:42  白云辉  阅读(319)  评论(0编辑  收藏  举报