选择下一个单元格 JTable
我想制作一个 jTable,其中当用户选择不可编辑的单元格时,它应该自动将焦点更改到下一个可编辑的单元格。重要提示:用户可以通过键盘(选项卡或箭头)和鼠标单击来选择单元格。是否可以??怎么去呢?
I would like to make a jTable in which when user select an uneditable cell then it should change focus to the next editable cell automatically. Important: the user could select a cell by keyboard (tab or arrow) and by mouse clicking. Is it possible?? How to to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此链接详细介绍了以编程方式在 JTable 组件中进行选择;你必须将鼠标监听器/等链接起来才能解决这个问题。
This link details Programmatically Making Selections in a JTable Component; you'd have to have mouselisteners/etc chained to work off this.
表格选项卡展示了如何使用键盘进行操作。
我从未尝试过,但当您单击单元格时,您应该能够使用 MouseListener 来调用相同的操作。
刚刚对 MouseListener 进行了快速测试,它似乎工作正常:
Table Tabbing shows how you can do it with the keyboard.
I've never tried it but you should be able to use a MouseListener to invoke the same Action when you click on a cell.
Just did a quick test for the MouseListener and it seems to work fine: