I'm making a little Notepad program because I am very bored and thought I would try to implement a "Find" feature within my program.
I want to highlight every word that matches a given string.
here is the main chunk of code
if(e.getSource() == m_find){
String s = (String)JOptionPane.showInputDialog("Find Word", "Please search a word");
if(m_area.getText().contains(s)){
int start = m_area.getText().indexOf(s);
int length = start + s.length();
try {
highlight.addHighlight(start, length, painter);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}
This only gets the first occurrence of the word, how would I be able to high every occurrence of the word.