Jump Scrollbar Model
Posted by Darryl Burke on April 18, 2009
The default, and usually desired, behavior of a scrollbar is to continuously scroll its associated component while the scroll thumb is being dragged. There are at least two situations where this behavior may lead to a sluggish and unresponsive GUI:
- A complicated custom renderer bogs down the processor
- The contents to display are dynamically loaded from disk as the portions of the scrollable component are shown.
JumpScrollBarModel provides a behavior akin to clearing the option “Show window contents while dragging” on Windows. The scrollable component’s position will remain fixed while dragging the scroll thumb, and will update when the drag is terminated by releasing the mouse button. An optional setting allows for updating the scroll position when the mouse is paused for a user-defined interval.
A comprehensive set of constructors and overloads of the static utility method setJumpScrollBarModel make setting a JumpScrollBarModel a no-brainer. The simulation below shows the behavior of a JumpScrollBarModel set with the line
JumpScrollBarModel model =
JumpScrollBarModel extends DefaultBoundedRangeModel.