JTextPane not showing selection after losing focus
I've created a simple GUI with a JToolBar with three JButtons. There is also a JTextPane. Each button corresponds to either Bold, Italic, or Underline. The effect i'm going for is that when text is selected in the TextPane and I click one of the buttons, the corresponding effect from the button is applied to the text. That part is working fine. What's wrong is that as soon as I click a button the selection in the TextPane is no longer highlighted, but I can keep on clicking the other buttons and the effects are being applied to where the highlighted selection should be.
I've very crudely set up a quick fix for it by having the TextPane request focus after a button is clicked. I know that that's not the right way to do it. I looked at the sample code for the TextComponentDemo in the Swing Trail Tutorials, but I couldn't figure out why they're code is doing it and mine isn't.
Any help would be great. Thank you.

