禁用滚动到焦点单元格
我在滚动窗格内有一个 jtable 。当部分不在视图范围内的单元格获得焦点时,如何阻止滚动窗格向上或向下滚动?
问题是,当用户将鼠标悬停在单元格上时,我将单元格设置为可编辑,因此当您将鼠标悬停在部分不可见的单元格上时,视图会突然发生变化。我不喜欢这种行为。关于如何改变它有什么想法吗?
I have a jtable inside of a scrollpane. how can i stop the scrollpane from scrolling up or down when a cell that is partly out of view gains focus?
the problem is i am setting the cells to editable when the user mouses over them, so when you mouse over a cell that's partly out of view, the view changes suddenly. I don't like this behaviour. any ideas on how to change it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试在桌子上调用“setAutoscrolls(false)”。
尽管 javadoc 讨论了处理鼠标拖动事件,但它也应该禁用行/单元格部分的滚动。
You could try calling "setAutoscrolls(false)" on your table.
Although the javadoc talks about handing mouse drag events, it should also disable scrolling on row/cell sections also.
我花了几个小时的时间进行搜索,但我让它为我工作。
使用您的 JTable 子类覆盖此方法
现在
table.setAutoscrolls(false)
应该可以正常工作。Took me hours of searching but I got it to work for me.
Override this method with your JTable subclass
Now
table.setAutoscrolls(false)
should work properly.