更新 JscrollBar 而不重置位置
我有一个扩展 JScrollPane 的类,它的视口是另一个扩展 JComponent 并实现 Scrollable 的类。当组件的大小发生变化时,除非我调用 revalidate(),否则 JscrollBars 不会更新,但这会将滚动条的位置重置为左上角。有没有办法在保持滚动条当前位置的同时更新滚动条的大小?
谢谢,罗布
I have a class which extends JScrollPane, its viewport is another class which extends JComponent and implements Scrollable. When the size of the component changes the JscrollBars do not update unless I call revalidate() however this resets the position of the scroll bars to the top left. Is there a way of updating the size of the scroll bars while maintaining their current position?
Thanks, Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您的自定义滚动窗格还是您的自定义组件?我们无法开始猜测您可能做出了什么样的改变。发布您的 SSCCE 来演示该问题。
它对我来说效果很好。
Is the problem your custom scroll pane or your custom component? We can't begin to guess what kind of changes you may have made. Post your SSCCE that demonstrates the problem.
It works fine for me.