如何区分由于用户单击或由于列拖动而调用 isCellEditable()
我有一个带有自定义编辑器和渲染器的 JTable。我也有我的表格模型。当用户单击特定列的单元格时,我想实例化一个特殊的输入窗口。我已经在 isCellEditable() 中编写了逻辑,但现在的问题是,当我单击该特定列的任何单元格时,会弹出输入窗口,然后我输入我的值,直到现在一切正常。但是现在,当我尝试通过拖动标题来移动列位置时,再次调用 isCellEditable() ,并且没有任何用户单击该特定列的单元格,就会弹出窗口。 请建议如何区分用户单击和列拖动。
问候 克里希纳
I have a JTable with custom editor and renderer. I have my table model also.I want to instantiate an special input window when user clicks on a cell of an specific column. I have written the logic in isCellEditable() but now the problem is that when I click on any cell of that specific column then the input window pops up then I input my value until now every thing works fine. But now when I try to shift the column position by dragging the header then again isCellEditable() is called and without any user click on the cell of that specific column the window pops up.
Kindly suggest how to differentiate between a user click and column dragging.
Regards
Krishna
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我无法找到问题的答案,但我的目的已经解决了。我在类中编写了实例化复杂窗口的所有逻辑: CustomCellRenderer 、 getTableCellEditorComponent()。我的 CustomCellRenderer 扩展了 DefaultCellEditor。我犯的唯一错误是在逻辑中调用表模型的 setValueAt() 。后来我发现我可以选择在 getTableCellEditorComponent() 中自行设置组件的值。随后返回相同的组件。
although I was not able to find an answer to my question but I got my purpose solved. I wrote all my logic of instantiating the complex window in my class: CustomCellRenderer , getTableCellEditorComponent(). My CustomCellRenderer extends DefaultCellEditor. The only mistake I was doing was calling the setValueAt() of the table model in the logic. Later I found that I had the option of setting the value of the component in the getTableCellEditorComponent() it self. Later the same component is returned.