I have to highlight the all occurrences of a word in JEditorPane
. For this I am using the following code:
try
{
javax.swing.text.DefaultHighlighter.DefaultHighlightPainter highlightPainter =
new javax.swing.text.DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);
textPane.getHighlighter().addHighlight(startPos, endPos,
highlightPainter);
}
catch(Exception ex)
{
}
But how can I give the position of index of a word?
I am reading the content from file but it is reading the HTML tags also and it is disturbing the index of words.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…