如何区分由于用户单击或由于列拖动而调用 isCellEditable()

发布于 2024-10-11 12:28:16 字数 257 浏览 1 评论 0原文

我有一个带有自定义编辑器和渲染器的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彡翼 2024-10-18 12:28:16

虽然我无法找到问题的答案,但我的目的已经解决了。我在类中编写了实例化复杂窗口的所有逻辑: 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文