MyHighlightPainter myHighlightPainter = new MyHighlightPainter(Color.yellow);
removeHighlights(textComp);
if (pattern.length() > 0)
try {
Highlighter hilite = textComp.getHighlighter();
Document doc = textComp.getDocument();
String text = doc.getText(0, doc.getLength());
text = text.toUpperCase();
pattern = pattern.toUpperCase();
int pos = textComp.getCaretPosition();
if ((pos = text.indexOf(pattern, pos)) != -1)
if (findAll == 0) {
hilite.addHighlight(pos, pos + pattern.length(), myHighlightPainter);
textComp.setCaretPosition(pos + pattern.length());
textComp.setSelectionStart(pos);
textComp.setSelectionEnd(pos + pattern.length());
} else {
for (; (pos = text.indexOf(pattern, pos)) >= 0; pos += pattern.length())
hilite.addHighlight(pos, pos + pattern.length(), myHighlightPainter);
}
} catch (BadLocationException badlocationexception) {
}
}