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 JCheckBox
es 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.
精彩评论