【发布时间】:2014-10-31 13:27:21
【问题描述】:
我可以在 JScrollBar 上定义不同的滚动速度吗?
例如,假设我们有一个高度为 1000 的图像不适合我的框架。因此,我创建了一个默认的 JScrollBar,假设 viewport 的高度为 200:
[^]
(*) -> The topmost pixel in the frame has height 0 of the image
|
|
|
|
[v]
[^]
|
(*) -> The topmost pixel in the frame has height 200 of the image
|
|
|
[v]
[^]
|
|
(*) -> The topmost pixel in the frame has height 400 of the image
|
|
[v]
现在我的问题是:我可以改变这种行为吗?例如,我希望它以下列方式运行:
[^]
(*) -> The topmost pixel in the frame has height 0 of the image!
|
|
|
|
[v]
[^]
|
(*) -> The topmost pixel in the frame has height 300 of the image!
|
|
|
[v]
[^]
|
|
(*) -> The topmost pixel in the frame has height 650 of the image!
|
|
[v]
滚动条看起来仍应与以前相同,但各个滚动速度会根据旋钮在滚动条上的位置而变化。理想情况下,我想定义一些滚动速度保持不变的区域。这个问题可能听起来很奇怪,但我需要这样的机制,因为我正在动态绘制JScrollBar 的组件,而且我事先不知道它的确切大小。这种行为甚至可以在 Swing 中实现吗?
【问题讨论】:
-
JScrollBar 返回最小值和最大值,使用此值进行滚动增量