datalogo
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

Filling Graphics with Color

These commands will draw the figure and fill the space with color. 

EDGE:  If you want a distinct "edge" around the figure, also draw the figure in a contrasting color after the fill command. 

  g.setColor(Color.orange);
g.fillRect(35,45,75,95);

     3

 
g.setColor(Color.orange);
g.fillRect(35,45,75,95);
g.setColor(Color.black);
g.drawRect(35, 45, 75, 95);


        1
 
Fill an Arc g.fillArc(35, 45, 75, 95, 0, 90);

Draws and fills an arc with a previously set color.

4

Fill an Oval g.fillOval(35, 45, 75, 95);

Draws and fills an oval with a previously set color.

5

Fill a Rectangle g.fillRect(35, 45, 75, 95);

Draws and fills a rectangle with a previously set color.

2

Fill a Round Rectangle

 

g.fillRoundRect(2,2,25,35,20,20);

Draws and fills with a previously set color.

7

Fill a Polygon

 

int [ ] x = {20, 20, 30, 50, 30, 20};
int [ ] y = {10, 25, 35, 40, 35, 30};
g.fillPolygon(x, y, 6);

Draws and fills a polygon with a previously set color.

6

divider
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

Notice: These materials are free for your on-line use at this site, but are not free for the taking.
Please do not copy these materials or re-post them to the Internet, as it is copyright infringement.
If you wish hard-copies of these materials, refer to our subscription area, JavaMathBits.com.
Help us keep these resources free. Thank you.