开发者

How can double-clicking be disabled for just one portion of a JTable?

I have a JTable with row selection enabled. Before today, my desired functionality was for double-clicking on any given row to open up a new window. And before today, that worked just fine.

I've just added a column of JCheckBoxes to th开发者_如何学Ce table. Selecting and deselecting individual checkboxes in the new column works fine, in general. However, if I select a checkbox and quickly deselect it, the table interprets my actions as a double-click on the checkbox's row, which is not what I want.

Is there a way to disable the double-clicking behavior for just the checkboxes, but keeping row selection enabled otherwise? If not, how about disabling the behavior for just one column of a table? If so, how?


If not, how about disabling the behavior for just one column of a table?

Use the table.columnAtPoint(...) method to ignore double clicks on the columm with the checkbox.


In the MouseListener you could check the state of the checkbox of the selected row for each click and if the second click's state doesn't match the first click's state then don't open a new window.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜