Class FSScrollPane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants

public class FSScrollPane extends JScrollPane

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 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 XHTMLPanel should save you time as your users will 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);
 
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • PAGE_DOWN

      public static final String PAGE_DOWN
      Constant used for mapping a key binding to "scroll down 1 page"
      See Also:
    • PAGE_UP

      public static final String PAGE_UP
      Constant used for mapping a key binding to "scroll up 1 page"
      See Also:
    • LINE_DOWN

      public static final String LINE_DOWN
      Constant used for mapping a key binding to "scroll down 1 line"
      See Also:
    • LINE_UP

      public static final String LINE_UP
      Constant used for mapping a key binding to "scroll up 1 line"
      See Also:
    • PAGE_END

      public static final String PAGE_END
      Constant used for mapping a key binding to "scroll to end of document"
      See Also:
    • PAGE_START

      public static final String PAGE_START
      Constant used for mapping a key binding to "scroll to top of document"
      See Also:
  • Constructor Details

    • FSScrollPane

      public FSScrollPane()
    • FSScrollPane

      public FSScrollPane(JPanel view)
      Instantiates a new FSScrollPane around the given Panel; see class documentation.
  • Method Details

    • setViewportView

      public void setViewportView(Component view)
      Overrides:
      setViewportView in class JScrollPane
    • setDefaultInputMap

      private void setDefaultInputMap(JComponent view)
      Assigns the default keyboard bindings on the view for document navigation.
    • setDefaultActionMap

      private void setDefaultActionMap(JComponent view)
      Assigns the default Actions for document navigation on the view.
    • addResizeListener

      private void addResizeListener(Component view)
      Adds a component listener on the view for resize events, to adjust the scroll increment.