Class RTextScrollPane

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

public class RTextScrollPane extends JScrollPane
An extension of JScrollPane that will only take RTextAreas (or javax.swing.JLayers decorating RTextAreas) for its view. This class has the ability to show:
  • Line numbers
  • Per-line icons (for bookmarks, debugging breakpoints, error markers, etc.)
  • +/- icons to denote code folding regions.
The actual "meat" of these extras is contained in the Gutter class. Each RTextScrollPane has a Gutter instance that it uses as its row header. The gutter is only made visible when one of its features is being used (line numbering, folding, and/or icons).
Version:
1.0
See Also:
  • Field Details

    • gutter

      private Gutter gutter
  • Constructor Details

    • RTextScrollPane

      public RTextScrollPane()
      Constructor. If you use this constructor, you must call setViewportView(Component) and pass in an RTextArea for this scroll pane to render line numbers properly.
    • RTextScrollPane

      public RTextScrollPane(RTextArea textArea)
      Creates a scroll pane. A default value will be used for line number color (gray), and the current line's line number will be highlighted.
      Parameters:
      textArea - The text area this scroll pane will contain.
    • RTextScrollPane

      public RTextScrollPane(Component comp)
      Creates a scroll pane. A default value will be used for line number color (gray), and the current line's line number will be highlighted.
      Parameters:
      comp - The component this scroll pane should display. This should be an instance of RTextArea, javax.swing.JLayer (or the older org.jdesktop.jxlayer.JXLayer), or null. If this argument is null, you must call setViewportView(Component), passing in an instance of one of the types above.
    • RTextScrollPane

      public RTextScrollPane(RTextArea textArea, boolean lineNumbers)
      Creates a scroll pane. A default value will be used for line number color (gray), and the current line's line number will be highlighted.
      Parameters:
      textArea - The text area this scroll pane will contain. If this is null, you must call setViewportView(Component), passing in an RTextArea.
      lineNumbers - Whether line numbers should be enabled.
    • RTextScrollPane

      public RTextScrollPane(Component comp, boolean lineNumbers)
      Creates a scroll pane. A default value will be used for line number color (gray), and the current line's line number will be highlighted.
      Parameters:
      comp - The component this scroll pane should display. This should be an instance of RTextArea, javax.swing.JLayer (or the older org.jdesktop.jxlayer.JXLayer), or null. If this argument is null, you must call setViewportView(Component), passing in an instance of one of the types above.
      lineNumbers - Whether line numbers should be enabled.
    • RTextScrollPane

      public RTextScrollPane(Component comp, boolean lineNumbers, Color lineNumberColor)
      Creates a scroll pane.
      Parameters:
      comp - The component this scroll pane should display. This should be an instance of RTextArea, javax.swing.JLayer (or the older org.jdesktop.jxlayer.JXLayer), or null. If this argument is null, you must call setViewportView(Component), passing in an instance of one of the types above.
      lineNumbers - Whether line numbers are initially enabled.
      lineNumberColor - The color to use for line numbers.
  • Method Details

    • checkGutterVisibility

      private void checkGutterVisibility()
      Ensures the gutter is visible if it's showing anything.
    • getGutter

      public Gutter getGutter()
      Returns the gutter.
      Returns:
      The gutter.
    • getLineNumbersEnabled

      public boolean getLineNumbersEnabled()
      Returns true if the line numbers are enabled and visible.
      Returns:
      Whether line numbers are visible.
      See Also:
    • getTextArea

      public RTextArea getTextArea()
      Returns the text area being displayed.
      Returns:
      The text area.
      See Also:
    • isFoldIndicatorEnabled

      public boolean isFoldIndicatorEnabled()
      Returns whether the fold indicator is enabled.
      Returns:
      Whether the fold indicator is enabled.
      See Also:
    • isIconRowHeaderEnabled

      public boolean isIconRowHeaderEnabled()
      Returns whether the icon row header is enabled.
      Returns:
      Whether the icon row header is enabled.
      See Also:
    • setFoldIndicatorEnabled

      public void setFoldIndicatorEnabled(boolean enabled)
      Toggles whether the fold indicator is enabled.
      Parameters:
      enabled - Whether the fold indicator should be enabled.
      See Also:
    • setIconRowHeaderEnabled

      public void setIconRowHeaderEnabled(boolean enabled)
      Toggles whether the icon row header (used for breakpoints, bookmarks, etc.) is enabled.
      Parameters:
      enabled - Whether the icon row header is enabled.
      See Also:
    • setLineNumbersEnabled

      public void setLineNumbersEnabled(boolean enabled)
      Toggles whether line numbers are visible.
      Parameters:
      enabled - Whether line numbers should be visible.
      See Also:
    • setViewportView

      public void setViewportView(Component view)
      Sets the view for this scroll pane. This must be an RTextArea.
      Overrides:
      setViewportView in class JScrollPane
      Parameters:
      view - The new view.
      See Also:
    • getFirstRTextAreaDescendant

      private static RTextArea getFirstRTextAreaDescendant(Component comp)
      Returns the first descendant of a component that is an RTextArea. This is primarily here to support javax.swing.JLayers that wrap RTextAreas.
      Parameters:
      comp - The component to recursively look through.
      Returns:
      The first descendant text area, or null if none is found.