java - Set caret position on JScrollPane -
i have jeditopane inside jscrollpane. have text content contain pre-defined tokens. i'm storing location of these tokens in database. when set text content jeditorpane, embed tokens html. add html break lines format content.
now problem comes when want scroll 1 of highlighted tokens. seems start position of tokens, stored in database, not match when using setcaretposition(int). know it's because content in jeditorpane document mixed html.
so there way search string in jeditorpane content, somehow caret position string found?
do strings have commonalities? if do, try using combination of java.util.scanner or/and java.util.regex.matcher. make sure right regex need. once have found string indexof first letter , set caret position it.
Comments
Post a Comment