FSScrollPane
is a JScrollPane set up to support keyboard navigation of an XHTML/XML document rendered with Flying Saucer. In particular, it assigns key bindings to the view's {@link InputMap} for page-up, page-down, line-up/down, page-start and page-end. The amount the document scrolls is based on the current viewport and the current line height. If the view is resized, the scroll increment is automatically adjusted. Using FSScrollPane to display an {@link XHTMLPanel} should save you time as your userswill have standard keyboard navigation out of the box.
To use FSScrollPane
, just instantiate it and add your XHTMLPanel on instantiation:
XHTMLPanel panel = new XHTMLPanel(); FSScrollPane scroll = new FSScrollPane(view);
The current input mappings to keys are:
- Scroll to Start
- CONTROL-HOME or HOME
- Scroll Up 1 Page
- PAGEUP
- Scroll Up 1 Line
- UP-ARROW
- Scroll to Bottom
- CONTROL-END or END
- Scroll Down 1 Page
- PAGEDOWN
- Scroll Down 1 Line
- DOWN-ARROW
This class declares six constant strings you can use if you want to override one of these default settings on the
InputMap
; these Strings will be trigger the relevant
Action
associated with the scrolling. To change the key binding for "Scroll to Top" to
Alt-Home
, do this:
panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW). put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, KeyEvent.ALT_MASK), FSScrollPane.PAGE_START);
@author Patrick Wright