你的位置:首页 > Java教程

[Java教程]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")    }  }}