APIdia Launch Partner
Top Description Inners Methods
javax.swing.text

public Interface Highlighter

Known Direct Implementers
javax.swing.text.LayeredHighlighter
Imports
java.awt.Color, .Graphics, .Shape

An interface for an object that allows one to mark up the background with colored areas.
Author
Timothy Prinzing

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static interface
Highlighter.HighlightPainter

Highlight renderer.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

an object that refers to the highlight
addHighlight
(int
the beginning of the range >= 0
p0
,
int
the end of the range >= p0
p1
,
Highlighter.HighlightPainter
the painter to use for the actual highlighting
p
)

Adds a highlight to the view.

public void
changeHighlight(Object
which highlight to change
tag
,
int
the beginning of the range >= 0
p0
,
int
the end of the range >= p0
p1
)

Changes the given highlight to span a different portion of the document.

public void
deinstall(JTextComponent
the JTextComponent editor
c
)

Called when the UI is being removed from the interface of a JTextComponent.

public Highlighter.Highlight[]

Returns:

the highlight list
getHighlights
()

Fetches the current list of highlights.

public void
install(JTextComponent
the JTextComponent editor
c
)

Called when the UI is being installed into the interface of a JTextComponent.

public void
paint(Graphics
the graphics context.
g
)

Renders the highlights.

public void
removeAllHighlights()

Removes all highlights this highlighter is responsible for.

public void
removeHighlight(Object
which highlight to remove
tag
)

Removes a highlight from the view.

Method Detail

addHighlightback to summary
public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException

Adds a highlight to the view. Returns a tag that can be used to refer to the highlight.

Parameters
p0:int

the beginning of the range >= 0

p1:int

the end of the range >= p0

p:Highlighter.HighlightPainter

the painter to use for the actual highlighting

Returns:Object

an object that refers to the highlight

Exceptions
BadLocationException:
for an invalid range specification
changeHighlightback to summary
public void changeHighlight(Object tag, int p0, int p1) throws BadLocationException

Changes the given highlight to span a different portion of the document. This may be more efficient than a remove/add when a selection is expanding/shrinking (such as a sweep with a mouse) by damaging only what changed.

Parameters
tag:Object

which highlight to change

p0:int

the beginning of the range >= 0

p1:int

the end of the range >= p0

Exceptions
BadLocationException:
for an invalid range specification
deinstallback to summary
public void deinstall(JTextComponent c)

Called when the UI is being removed from the interface of a JTextComponent. This is used to unregister any listeners that were attached.

Parameters
c:JTextComponent

the JTextComponent editor

getHighlightsback to summary
public Highlighter.Highlight[] getHighlights()

Fetches the current list of highlights.

Returns:Highlighter.Highlight[]

the highlight list

installback to summary
public void install(JTextComponent c)

Called when the UI is being installed into the interface of a JTextComponent. This can be used to gain access to the model that is being navigated by the implementation of this interface.

Parameters
c:JTextComponent

the JTextComponent editor

paintback to summary
public void paint(Graphics g)

Renders the highlights.

Parameters
g:Graphics

the graphics context.

removeAllHighlightsback to summary
public void removeAllHighlights()

Removes all highlights this highlighter is responsible for.

removeHighlightback to summary
public void removeHighlight(Object tag)

Removes a highlight from the view.

Parameters
tag:Object

which highlight to remove

javax.swing.text back to summary

public Interface Highlighter.Highlight

Known Direct Implementers
javax.swing.text.DefaultHighlighter.HighlightInfo

A highlight.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the ending offset >= 0
getEndOffset
()

Gets the ending model offset for the highlight.

public Highlighter.HighlightPainter

Returns:

the painter
getPainter
()

Gets the painter for the highlighter.

public int

Returns:

the starting offset >= 0
getStartOffset
()

Gets the starting model offset for the highlight.

Method Detail

getEndOffsetback to summary
public int getEndOffset()

Gets the ending model offset for the highlight.

Returns:int

the ending offset >= 0

getPainterback to summary
public Highlighter.HighlightPainter getPainter()

Gets the painter for the highlighter.

Returns:Highlighter.HighlightPainter

the painter

getStartOffsetback to summary
public int getStartOffset()

Gets the starting model offset for the highlight.

Returns:int

the starting offset >= 0

javax.swing.text back to summary

public Interface Highlighter.HighlightPainter

Known Direct Implementers
javax.swing.text.LayeredHighlighter.LayerPainter

Highlight renderer.

Method Summary

Modifier and TypeMethod and Description
public void
paint(Graphics
the graphics context
g
,
int
the starting offset in the model >= 0
p0
,
int
the ending offset in the model >= p0
p1
,
Shape
the bounding box for the highlight
bounds
,
JTextComponent
the editor
c
)

Renders the highlight.

Method Detail

paintback to summary
public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c)

Renders the highlight.

Parameters
g:Graphics

the graphics context

p0:int

the starting offset in the model >= 0

p1:int

the ending offset in the model >= p0

bounds:Shape

the bounding box for the highlight

c:JTextComponent

the editor