Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-06-2004, 07:19 AM   #1 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Question 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

Code:
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

Last edited by freesoft_2000; 12-06-2004 at 07:51 AM.
freesoft_2000 is offline   Reply With Quote
Old 12-06-2004, 07:38 AM   #2 (permalink)
kaeli69
Registered User
 
kaeli69's Avatar
 
Join Date: Apr 2003
Posts: 30
kaeli69 is an unknown quantity at this point
Quote:
Originally Posted by freesoft_2000
Here is what i have been doing

Code:
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?
It compiles fine. It runs fine. The problem - you have nothing assigned to happen when Color1 IS null.
Therefore, what is probably happening is that Color1 is null.
Throw an else in there to pop an error if Color1 is null and see if it fires. If it does, you have to figure out why that is.

HTH
kaeli69 is offline   Reply With Quote
Old 12-06-2004, 07:40 AM   #3 (permalink)
kaeli69
Registered User
 
kaeli69's Avatar
 
Join Date: Apr 2003
Posts: 30
kaeli69 is an unknown quantity at this point
Oh, and convention would state that a method that is a setter for a variable named "color" would be setColor, not setcolor. Note the case of the letter C. And yes, it DOES matter if this will ever be a bean.
kaeli69 is offline   Reply With Quote
Old 12-06-2004, 12:34 PM   #4 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Hi everyone,
I added an else and it still does not work and color1 is not null. I really have no idea what else to try.

Richard West
freesoft_2000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
colors falsepride HTML, XML, Javascript, AJAX 2 11-08-2004 12:05 PM
Background Resolution Lebby HTML, XML, Javascript, AJAX 1 06-16-2004 07:35 AM
html background resolutions do_guh_new HTML, XML, Javascript, AJAX 7 05-19-2003 12:29 PM


All times are GMT -8. The time now is 12:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting