static Map < Point , Object > addHighlights ( JTextComponent textComponent , Iterable < ? extends Point > appearances , Color color ) { Highlighter . HighlightPainter painter = new DefaultHighlighter . DefaultHighlightPainter ( color ) ; Highlighter highlighter = textComponent . getHighlighter ( ) ; Map < Point , Object > highlights = new LinkedHashMap < Point , Object > ( ) ; for ( Point appearance : appearances ) { try { Object highlight = highlighter . addHighlight ( appearance . x , appearance . y , painter ) ; highlights . put ( appearance , highlight ) ; } catch ( BadLocationException e ) { // Should never happen logger . severe ( e . toString ( ) ) ; } } return highlights ; }
Add the given highlights to the given text component .