Hi,
If I have an HTML document, and want to search for and highlight a
string in the document, is there an easy way of getting from the
character positions in the raw HTML to the corresponding selection point
in a JEditorPane?
e.g. My html is:
<html><head></head><body><h1>header</h1>text</body>
If I search for "header" in the raw html, I get position 29. But in the
JEditor Pane, to highlight it, I need to setCaretPosition(0),
moveCaretPosition(6).
Is there a way of doing this? i.e. working out that the rendered caret
position for an arbitrary html document substring?
Regards
Rogan

Signature
Rogan Dawes
*ALL* messages to discard@dawes.za.net will be dropped, and added
to my blacklist. Please respond to "nntp AT dawes DOT za DOT net"
andreas - 17 Sep 2004 20:41 GMT
> Hi,
>
[quoted text clipped - 13 lines]
> Is there a way of doing this? i.e. working out that the rendered caret
> position for an arbitrary html document substring?
if you only parse text and not html code, maybe
you should parse editorPane.getText() instead of the raw html?
i don't know if this works, it is only a guess...
andreas
Rogan Dawes - 20 Sep 2004 07:55 GMT
>>Hi,
>>
[quoted text clipped - 19 lines]
>
> andreas
Thanks for the suggestion, but this does not work :-(
Rogan

Signature
Rogan Dawes
*ALL* messages to discard@dawes.za.net will be dropped, and added
to my blacklist. Please respond to "nntp AT dawes DOT za DOT net"
Toqwaz - 21 Sep 2004 16:53 GMT
Strip all html tags, this is one of the ways to do that:
String noHTMLString = htmlString.replaceAll("\\<.*?\\>","");