JScrollPane 中的滚动更平滑
使用 JScrollPane 的滚动条箭头进行滚动(或通过为箭头键设置键绑定)将视口移动一个增量,暂停,然后平滑滚动。我遇到的大多数滚动条的行为都是一样的;有轻微的移动、暂停,然后更快地连续滚动。有什么方法可以避免暂停,以便滚动从开始到结束都很流畅?
Using a JScrollPane's scrollbar arrows to scroll (or by setting up key bindings for the arrow keys) moves the viewport one increment, pauses, then scrolls smoothly. Most scrollbars I've encountered behave the same; there's a slight movement, a pause, and then faster continuous scrolling. Is there any way to avoid the pause, so that scrolling is smooth from start to finish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按键事件的初始延迟和重复率由主机操作系统指定。用户经常在主机的(取决于平台)首选项控制面板中调整默认值。类似地,
BasicScrollBarUI
平台的子类可以进一步调节限制,例如com.apple.laf.AquaScrollBarUI
v.javax.swing.plaf.metal.MetalScrollBarUI< /代码>。
由于这些设置可能根深蒂固或高度个性化,因此任意更改可能不会被接受。
The initial delay and repeat rate for key events is specified by the host operating system. Users often adjust the default values in the host's (platform dependent) preference control panel. Similarly, a platform's subclass of
BasicScrollBarUI
may further condition the throttling, e.g.com.apple.laf.AquaScrollBarUI
v.javax.swing.plaf.metal.MetalScrollBarUI
.As these settings may be deeply ingrained or highly personalized, arbitrary changes may be poorly received.
BasicScrollBarUI
负责设置执行滚动的计时器。您可以看到重复率比初始延迟快。
所以我猜你需要创建一个自定义滚动条 UI 并覆盖该代码。
The
BasicScrollBarUI
is responsible for setting up the timer that does the scrolling.You can see that the repeat rate is faster than the initial delay.
So I would guess you need to create a custom scrollbar UI and override that code.