在JScrollPane中更顺畅地滚动 [英] Smoother scrolling in a JScrollPane

查看:143
本文介绍了在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?

推荐答案

BasicScrollBarUI 负责设置滚动的计时器。

The BasicScrollBarUI is responsible for setting up the timer that does the scrolling.

private final static int scrollSpeedThrottle = 60; // delay in milli seconds
...
scrollListener = createScrollListener();
scrollTimer = new Timer(scrollSpeedThrottle, scrollListener);
scrollTimer.setInitialDelay(300);  // default InitialDelay?

您可以看到重复率快于初始延迟。

You can see that the repeat rate is faster than the initial delay.

所以我猜你需要创建一个自定义滚动条UI并覆盖该代码。

So I would guess you need to create a custom scrollbar UI and override that code.

这篇关于在JScrollPane中更顺畅地滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆