# Why doesn't My SetFillColor() work?

Printable View

• 05-11-2010, 12:46 PM
javanoob1
Why doesn't My SetFillColor() work?
Hi there,

I'm trying to create a rainbow and this is what I did...all I've managed to get is 6 ugly arches, but I can't make the SetFillColor() method to set each oval's color...can anyone please help?!:confused:

Thanks!

Code:

```import acm.program.*; import acm.graphics.*; import java.awt.*; public class Rainbow extends GraphicsProgram {         public void run() {                 setBackground(Color.cyan);                 int arcX = -(getWidth()/6);                 int arcY = getHeight()/8;                 int x = getWidth()*3/2;                 int y = getHeight()*2+300;                 for (int i=0; i<=6;i++){                         GOval arc = new GOval(arcX, arcY, x, y);                         add(arc);                         arcX-=10;                         arcY+=50;                         if (i==0) {arc.setFillColor(Color.red);}                         if (i==1) {arc.setFillColor(Color.orange);}                         if (i==2) {arc.setFillColor(Color.yellow);}                         if (i==3) {arc.setFillColor(Color.green);}                         if (i==4) {arc.setFillColor(Color.blue);}                         if (i==5) {arc.setFillColor(Color.magenta);}                         if (i==6) {arc.setFillColor(Color.cyan);}                 }         } }```
• 04-04-2011, 11:14 PM
nome
you have to do a setFilled(true);