使用 JTable 和 JScroll 窗格进行滚动锁定
我有一个使用 EventTableModel
并且位于 JScrollPane 中。 EventTableModel 从事件列表中获取实时更新并将结果显示在表中。当新结果进入表中时,新的信息将显示在表的顶部。
但是,我想要做的是冻结表格以显示当我按下名为“锁定表格”的按钮时当前显示的内容。此按钮应与 Eclipse 控制台“Scroll Lock”具有相同的效果,因此当新项目出现时,当前项目应保留在屏幕上,并且不会在新项目出现时被推开。但新项目仍应添加,只是不会自动滚动到。
有谁知道我如何尝试实现此功能。这样,当更新到来时,表上的数据不会被迫离开屏幕,因此当按下复选框时,焦点仍保留在当前数据上。
感谢您的任何帮助。 迈克尔
I have a JTable which is created with the use of an EventTableModel
and is in a JScrollPane. The EventTableModel takes live updates from an eventList and displays the result in the table. As new results come into the table and the new piece of information is displayed at the top of the table.
However, what I want to be able to do is freeze the table to show what is currently displayed when I press a button called 'Lock Table'. This button should have the same effect as the eclipse console 'Scroll Lock', therefore as new items appear the current items should remain on the screen and not be pushed off as new items appear. But new items should still be added just not automatically scrolled to.
Does anyone know how I can try achieve this functionality. So that as update come in, the data that is on the table is not forced off screen, therefore focuses remain on the current data when the check box is pressed.
Thanks for any help.
Michael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本过程(用于在当前显示区域上方插入)
恒定工作代码(使用 JXTable,因为它有方便的滚动方法,对于核心表,只需自己进行计算:-)
Basic procedure (for inserting above the current display area)
some working code (using JXTable, as it has convenience method for scrolling, for a core table simply do the calculations yourself :-)