Hi,
I'm tring to use different colors for different texts with JTextPane but without success. can someone help ?

Here is the code I have:
// parameters declaration
String firstStr = "hello";
String secondStr = "hello2";

// get text from file and print into the Text Pane by define different text style for this document.
m_TextPane.setText(""); // clear Text Pane from previous texts.
StyledDocument doc = m_TextPane.getStyledDocument();
Style def = StyleContext.getDefaultStyleContext().
getStyle(StyleContext.DEFAULT_STYLE);
Style regular = doc.addStyle("regular", def);
Style bold = doc.addStyle("bold", regular);
StyleConstants.setBold(bold, true);

doc.insertString(doc.getLength(), firstStr,doc.getStyle("bold"));
doc.insertString(doc.getLength(), secondStr,doc.getStyle("regular"));

I managed to create different styles for bold and regular text, but now I want to add color to the bold text or to its backgrond.

Thanks, Guy.