• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

backgroundColor

 
michael huang
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
when i look at the API doc, i found Graphics has two method: fillRect(), clearRect(). fillRect() use current Color and clearRect() use backgroundColor, i can use setColor() set current Color, how can i set backgroundColor? where is the backgroundColor?
thanks
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
I found this in the Java 2 specs:
public abstract void clearRect(int x,
int y,
int width,
int height)

Clears the specified rectangle by filling it with the background color of the current drawing surface. This operation does not use the current paint mode.
Beginning with Java 1.1, the background color of offscreen images may be system dependent. Applications should use setColor followed by fillRect to ensure that an offscreen image is cleared to a specific color.
Hope this helps.
Stephanie
 
michael huang
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephanie, thanks a lot
is that means background color depend on system, you can not set?
and what is the current paint mode, that means paint()?
thanks
michael
 
Jane Griscti
Ranch Hand
Posts: 3141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
There is a setBackground() method for Components. You could use it to set the background color of the object containing the rectangle.
Hope that helps.
 
kannan_al
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friend,
You can use the setBackground(Color.___) method to set the background for any GUI control components,frames, etc..

kannan.
 
michael huang
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I C,
i'll test it

thanks
michael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic