Class Markers


  • public class Markers
    extends java.lang.Object
    This class contains static utility methods to make highliting in text components easier.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Markers.SimpleMarker  
    • Constructor Summary

      Constructors 
      Constructor Description
      Markers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void markAll​(javax.swing.text.JTextComponent pane, java.util.regex.Pattern pattern, Markers.SimpleMarker marker)
      Mark all text in the document that matches the given pattern
      static void markText​(javax.swing.text.JTextComponent pane, int start, int end, Markers.SimpleMarker marker)
      add highlights for the given region on the given pane
      static void markToken​(javax.swing.text.JTextComponent pane, Token token, Markers.SimpleMarker marker)
      add highlights for the given Token on the given pane
      static void removeMarkers​(javax.swing.text.JTextComponent editorPane)
      Remove all the markers from an JEditorPane
      static void removeMarkers​(javax.swing.text.JTextComponent component, Markers.SimpleMarker marker)
      Removes only our private highlights This is public so that we can remove the highlights when the editorKit is unregistered.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Markers

        public Markers()
    • Method Detail

      • removeMarkers

        public static void removeMarkers​(javax.swing.text.JTextComponent component,
                                         Markers.SimpleMarker marker)
        Removes only our private highlights This is public so that we can remove the highlights when the editorKit is unregistered. SimpleMarker can be null, in which case all instances of our Markers are removed.
        Parameters:
        component - the text component whose markers are to be removed
        marker - the SimpleMarker to remove
      • removeMarkers

        public static void removeMarkers​(javax.swing.text.JTextComponent editorPane)
        Remove all the markers from an JEditorPane
        Parameters:
        editorPane -
      • markToken

        public static void markToken​(javax.swing.text.JTextComponent pane,
                                     Token token,
                                     Markers.SimpleMarker marker)
        add highlights for the given Token on the given pane
        Parameters:
        pane -
        token -
        marker -
      • markText

        public static void markText​(javax.swing.text.JTextComponent pane,
                                    int start,
                                    int end,
                                    Markers.SimpleMarker marker)
        add highlights for the given region on the given pane
        Parameters:
        pane -
        start -
        end -
        marker -
      • markAll

        public static void markAll​(javax.swing.text.JTextComponent pane,
                                   java.util.regex.Pattern pattern,
                                   Markers.SimpleMarker marker)
        Mark all text in the document that matches the given pattern
        Parameters:
        pane - control to use
        pattern - pattern to match
        marker - marker to use for highlighting