Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting a background color

 
tyler jones
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My book says to use the screen.setBackground(Color.white) to set the background color of my applet to white. However, when I compile this, I get an error. Is this setBackground method only available in certain versions of java? If not, anyone have any ideas why it might be throwing this error and not compiling? Thanks.
 
Noah Carroll
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is this screen variable you are using. did you set it up using
Container screen = getContentPane();
that is the way you are supposed to access the content pane when using swing applets or applications. if you aren't using swing im not sure what the problem is.
------------------
I hope its helps, feel free to email me noahcarroll@juno.com
 
Daniel Searson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this is the "right" way to do it, but I do the following to set the background color:
public void init() {
setBackground(Color.white);
// etc
}
------------------
- Daniel
 
tyler jones
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, that worked. For everything else so far, I was declaring my Graphics object like:
and then setting properties like this:

so naturally, I thought that to set the background color it would just be s.setBackground(Color.white); but it turned out just to be setBackground(Color.white). Thanks!!!
[This message has been edited by tyler jones (edited December 07, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic