Hi all ,

I had created a Document using jTextPane which I will use as a Template to create customize ones .

For eg :
I will create something like this in a Document using jTextPane

Hi <name>

and I will open this Document in another jTextPane to replace <name> with a user input word(say John) using inserString method of StyledDocument .

Everything is fine expect that I lost format of that (<name>) which I set in previously created Document .That is it's font attributes (bold ,italic ,underline style) are all changed to plain .

This is what I getting :

Hi John

and this is what I'm expecting :

Hi John.

Can any one tell me how to do that . That is replacing the word with out losing styles ?

Thanks in advance

Ezzaral ,thanks a lot for pointed out a useful link for my reference. It really helped.

This question has already been answered. Start a new discussion instead.