How can I get the selected word in the text from a `JTextPane` and then apply the Bold property for the selected-text by using the `Ctrl+B` Short Cut.

String are given to the `JTextpane` from the xml files. String are get from the tag elements and set to the `JTextpane`:

```
String selectedText = ta_textpane.getSelectedText();
int getselectedtextstart = ta_textpane.getSelectionStart();
int getselectedtextend = ta_textpane.getSelectionEnd();

String textbef = text.substring(0, getselectedtextstart);
String textaft = text.substring(getselectedtextend, text.length());
String textinbet = "<b>" + text.substring(getselectedtextstart,getselectedtextend) + "</b>";

String settoxmlfiletag = textbef + textinbet + textaft

```

After concat the `bold(<b>)`, write the bolded string to the xml tag. i have a Problem in getting the last index position and first index position because i use the `tamil` language in the `JTextPane`

Bold is applied but cannot be applied in the correct position.