2017-05-26 64 views
1

比方說,我宣佈使用SwingBuilder對象如下:獲得從Swing組件ID在Groovy SwingBuilder

swing.button(id:'something')

我知道我可以從SwingBuilder得到Component回來致電:

swing."something"

但是我怎樣才能從Component,返回到它的id作爲一個字符串?

Component c = getMyButton() 
String whatIWant = c.id //Property doesn't exist 
String attempt2 = c['id'] //Property doesn't exist 
+0

你有完整的代碼示例重現呢? – Rao

回答