sun.com/bugdatabase/view_bug.do?bug_id=4373575">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4373575. Sun claimed it is fixed but it is not as another user pointed it out at the end. If you run the test case provided by original submitter, you will immediately notice the tree node disappeared when you click on the tree nodes. This bug is actually one of the main reasons we decided to create StyledLabel. JTextPane is powerful and can display text in different color. But in the cases like cell renderer, JTextPane is obviously an overkill.
StyledLabel sits between JLabel and JTextPane and provides a very simple and fast way to display text in different color and style. It can also support decorations using all kinds of line styles.
All the methods on JLabel still work as before. The methods added in StyledLabel are several methods for StyleRange, such as {@link #addStyleRange(StyleRange)}, {@link #setStyleRanges(StyleRange[])}, {@link #clearStyleRange(StyleRange)}, and {@link #clearStyleRanges()}.
This is one thing about StyleRange that you should be aware of, which could be considered as a future enhancement item, is that the StyleRanges can't overlap with each other. For example, if you defined a StyleRange that covers from index 0 to index 3, you can't define any other StyleRange that overlaps with the first one. If you do so, the second StyleRange will be ignored.
We borrowed some ideas from SWT's StyledText when we designed StyledLabel, especially StyleRange concept. Saying that, the features of the two components are not exactly the same since the purpose of the two components are quite different.