• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

setting a background color

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic