public class TextSearcher extends Object
HTMLPane
Modifier and Type | Field and Description |
---|---|
protected JTextComponent |
comp |
Constructor and Description |
---|
TextSearcher(JTextComponent comp)
Constructor.
|
TextSearcher(JTextComponent comp,
String searchedText)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int[] |
getOffsets()
Gets the offsets of the searched text.
|
void |
highlight(int[] offsets,
Highlighter.HighlightPainter painter)
Highlights some portions of the text.
|
void |
highlight(int offset,
Highlighter.HighlightPainter painter)
Highlights a portion of the text.
|
boolean |
isCaseSensitive()
Tests whether the search is case sensitive or not.
|
boolean |
isDiacriticalSensitive()
Tests whether the search is diacritical sensitive or not.
|
void |
setCaseSentitive(boolean caseSensitive)
Sets if the search is case sensitive or not.
|
void |
setDiacriticalSensitive(boolean diacriticalSensitive)
Sets if the search is diacritical sensitive or not.
|
void |
setSearchedText(String text) |
protected JTextComponent comp
public TextSearcher(JTextComponent comp)
comp
- The text component in which to searchTextSearcher(JTextComponent, String)
public TextSearcher(JTextComponent comp, String searchedText)
comp
- The text component in which to searchsearchedText
- The text to searchpublic boolean isCaseSensitive()
public void setCaseSentitive(boolean caseSensitive)
caseSensitive
- true to have a case sensitive searchgetOffsets()
public boolean isDiacriticalSensitive()
public void setDiacriticalSensitive(boolean diacriticalSensitive)
diacriticalSensitive
- true to have a diacritical sensitive searchgetOffsets()
public int[] getOffsets()
highlight(int, javax.swing.text.Highlighter.HighlightPainter)
,
highlight(int[], javax.swing.text.Highlighter.HighlightPainter)
public void highlight(int[] offsets, Highlighter.HighlightPainter painter) throws BadLocationException
offsets
- the start of the portions to highlight (these offsets are returned by getOffsets method).
null to remove all highlights.painter
- The painter to be used (or null to use the default one).BadLocationException
- if offsets are out of text boundsgetOffsets()
public void highlight(int offset, Highlighter.HighlightPainter painter) throws BadLocationException
offset
- the start of the portion to highlight (one of the offsets returned by getOffsets method).painter
- The painter to be used (or null to use the default one).BadLocationException
- if offset is out of text boundsgetOffsets()
public void setSearchedText(String text)
Copyright © 2022. All rights reserved.