开发者

In Groovy SwingBuilder, how do I attatch a closure to a JTable that fires when a cell is selected?

I have a JTable bei开发者_运维百科ng constructed via Groovy's SwingBuilder. I'd like to attach a closure to the table that fires when a cell is selected, but I can't seem to find the right hook.

How do I do that?


I'm not an expert in groovy, but when inside the table element of the swingbuilder, you could use the Groovy way to implement interfaces. This works because ListSelectionListener only has one method.

table(id: 'myTable') {
    myTable.selectionModel.addListSelectionListener({evt->
            println("selection changed")
        } as ListSelectionListener)
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜