954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Background Colors

Hi everyone,

I have a weird problem. Currently i am using a jtextpane with the HTMLDocument class as its default document. I am tryin to change the
background colour of the htmldocument but still it does not seem to work. I cannot use the JTextPane's setBackground method as if i do that then i cannot save my document to disk as HTML file thus i am trying to change the background of the jtextpane by using the StyleConstants

Here is what i have been doing

public void setcolor()
{

  Color Color1 = ColorChooser1.showDialog(fr, "Color Chooser", Color.white);
      SimpleAttributeSet sas = new SimpleAttributeSet();

 if(Color1 != null)
    {
      StyleConstants.setBackground(sas, Color1);
      sas.addAttribute(HTML.Attribute.BGCOLOR, Color1);
    } 

}


The thing is when i use the above function nothing happens but compiles without any errors. Can anyone please help me out with this problem?

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You