I posted my response at 10:07. You replied at 10:10, which means you took less than 3 minutes to look at all the replies and that posting and run the demo code and understand what it does.
No wonder you don't understand, you can't even take time to try and figure it out.
The example code given there was based on the code from the Swing tutorial. Did you even bother to read the JTextPane API? Did you bother to follow the link to the Swing tutorial on "Text Component Features"?
Learn how to do some simple problem solving yourself and don't expect people to spoon feed the answers to you. I don't know what more you expect than a working example.