I would like to highlight(select) multiple occurrences of a string in JTextPane
. I would like to make something like findall. Here is what I have written.
int a=0;
while(jTextPane1.getText().indexOf(search,a)>0)
{
int i =jTextPane1.getText().indexOf(search,a);
a=i+search.length();
jTextPane1.select(i,a);
}
It works ok, but the problem is that it highlights only the last occurrence, because the highlight changes. I would like to make multiple highlights.