aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes backgroundColor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "backgroundColor" Watch "backgroundColor" New topic
Author

backgroundColor

michael huang
Ranch Hand

Joined: Jul 30, 2000
Posts: 63
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

Joined: Jun 14, 2000
Posts: 347
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

Joined: Jul 30, 2000
Posts: 63
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

Joined: Aug 30, 2000
Posts: 3141
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.


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
kannan_al
Greenhorn

Joined: Sep 09, 2000
Posts: 4
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

Joined: Jul 30, 2000
Posts: 63
I C,
i'll test it

thanks
michael
 
 
subject: backgroundColor