Hoping someone can help me layer highlights in a document.
I have implemented a find in the document that highlights all the instances of whatever the search word is and selects the one nearest the caret. This works very well. However, if you click somewhere else in the document the select is lost (correctly so) but I need that word (which was previously selected) to still be highlighted as it is still a correct instance of the found word.
I have tried adding a highlight (uncommenting the line below) and then the selection and setting the selection visible, but this only displays the highlight color and not the select. I need to layer the selection above the highlight so when the selection is moved, the highlight remains.
Any advice will greatly be appreciated.
//currentTextPane.getHighlighter().addHighlight(star t + foundPos, start + foundPos + s.length(), //editorHighlighter.highlightPainter);
currentTextPane.select(start + foundPos, start + foundPos + s.length());
- By the way the other highlights are added with this code
currentTextPane.getHighlighter().addHighlight(star t + foundPos, start + foundPos + s.length(), editorHighlighter.highlightPainter);