*/
protected void selectSubString(Element element, int charnum, int nchars){
AttributedCharacterIterator aci =
((TextNode)node).getAttributedCharacterIterator();
TextNode textNode = (TextNode)node;
int firstChar = getFirstCharacterIndexForElement(aci,element);
if ( firstChar == -1 )
return;
List list = getTextRuns(textNode);
int lastChar = getLastCharacterIndexForElement(aci,element);
CharacterInformation firstInfo = getCharacterInformation
(list, firstChar,charnum,aci);
CharacterInformation lastInfo = getCharacterInformation
(list, firstChar,charnum+nchars-1,aci);
Mark firstMark = textNode.getMarkerForChar(firstInfo.characterIndex,true);
Mark lastMark;
if ( lastInfo != null && lastInfo.characterIndex <= lastChar ){
lastMark = textNode.getMarkerForChar(lastInfo.characterIndex,false);
}
else{
lastMark = textNode.getMarkerForChar(lastChar,false);
}
textNode.setSelection(firstMark,lastMark);
}