如何更改 jtable 中的默认停止编辑行为
当您编辑 jtable 中的单元格时,仅当焦点更改或按下 Enter 键时,该值才会永久保存(例如,如果您将单元格值从“abc”更改为“xyz”并关闭窗口,则编辑将丢失) 。 当用户停止编辑时如何使编辑永久化?
我想我们必须在编辑单元格值时更新单元格值,但我不知道如何更新。 任何帮助表示赞赏!
提前致谢!
When you edit a cell in an jtable the value is made permanent only if the focus is changed or if one hits enter (for example if you change the cell value from "abc" to "xyz" and close the window the edit is lost). How do i make the edit permanent when the user stops editing?
I guess we have to update the cell value as the cell value is being editted but i am not sure how. Any help is appreciated!
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会在单元格上设置一个 ActionListener,在每次击键后将单元格的值保存到变量中(假设单元格具有焦点)。 然后,无论窗口发生什么情况,该变量仍将包含单元格中当前的内容。 很简单。
I would setup an ActionListener on the cell that saves the value of the cell to a variable after every keystroke (assuming the cell has focus). Then no matter what happens to the windows this variable will still contain whatever was currently in the cell. Pretty simple.