Highlighters determine how text is marked to make it stand
out. The order in which we discuss the highlighter interfaces may seem
counterintuitive. The basic
Highlighter interface is so straightforward
that you’ll rarely need to work with it directly, so we will describe it
later. At this point, we discuss the interface you’re most likely to use
This is an inner interface of the
Highlighter interface. If you want to change
the way that highlights are drawn in your text component, this is the
interface you’d implement.
Highlighter.HighlightPainter are returned by
Caret implementations and passed to
(described later in this section; there are a lot of interfaces
working together), which use them to decorate the area “behind” a
selection. The only concrete implementation that’s provided in Swing
which paints highlights as a solid background rectangle of a specified
This interface consists of a single
paint( ) method. Unlike the
paint( ) method of
Caret, this method is called before the text
itself is rendered, so there’s no need to worry about obscuring text
or XOR mode.
Render a highlighter behind the text of the specified
p1 parameters specify offsets into the document model ...