This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.text
interface Highlighter

All Known Implementing Classes:
LayeredHighlighter, DefaultHighlighter, BasicTextUI.BasicHighlighter

Most common way to construct:

JTextComponent comp = …;

Highlighter highlighter = comp.getHighlighter();

Based on 11 examples


public interface Highlighter

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


Nested Class Summary
static interface

          
static interface

           Highlight renderer.
 
Method Summary
 Object

          Adds a highlight to the view.
 void
changeHighlight(Object tag, int p0, int p1)

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

          Called when the UI is being removed from the interface of a JTextComponent.
 Highlighter.Highlight[]

          Fetches the current list of highlights.
 void

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

          Renders the highlights.
 void

          Removes all highlights this highlighter is responsible for.
 void

          Removes a highlight from the view.
 

Method Detail

addHighlight

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 - the beginning of the range >= 0
p1 - the end of the range >= p0
p - the painter to use for the actual highlighting
Returns:
an object that refers to the highlight
Throws:
BadLocationException - for an invalid range specification

changeHighlight

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 - which highlight to change
p0 - the beginning of the range >= 0
p1 - the end of the range >= p0
Throws:
BadLocationException - for an invalid range specification

deinstall

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 - the JTextComponent editor

getHighlights

public Highlighter.Highlight[] getHighlights()
Fetches the current list of highlights.

Returns:
the highlight list

install

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 - the JTextComponent editor

paint

public void paint(Graphics g)
Renders the highlights.

Parameters:
g - the graphics context.

removeAllHighlights

public void removeAllHighlights()
Removes all highlights this highlighter is responsible for.


removeHighlight

public void removeHighlight(Object tag)
Removes a highlight from the view.

Parameters:
tag - which highlight to remove


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.