开发者

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

开发者 https://www.devze.com 2022-12-09 11:37 出处:网络
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.

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

精彩评论

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