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.

[950 byte] By [adamkunzlera] at [2007-11-26 23:33:36]
# 1
button.setFocusable( false );Then when you click on your toolbar buttons focus will still remain on the text field.
camickra at 2007-7-11 14:53:17 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thank you very much. I don't know why I couldn't figure that out. Do JMenu's and JMenuItem's default to not being focusable? That would explain why I didn't see it in the Trail TextComponentDemo source code.
adamkunzlera at 2007-7-11 14:53:17 > top of Java-index,Desktop,Core GUI APIs...