Results 1 to 2 of 2
  1. #1
    javanoob1 is offline Member
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

    Default 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!

    Java 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);}
    		}
    	}
    
    }

  2. #2
    nome is offline Member
    Join Date
    Apr 2011
    Posts
    9
    Rep Power
    0

Similar Threads

  1. Need help with getting second loop to work
    By twcast in forum New To Java
    Replies: 3
    Last Post: 02-08-2010, 02:15 PM
  2. Why doesn't this work?
    By Corder10 in forum New To Java
    Replies: 1
    Last Post: 07-04-2009, 10:33 PM
  3. Synchronization Doesn't seem to work
    By sherinpearl in forum Threads and Synchronization
    Replies: 1
    Last Post: 04-23-2008, 06:30 PM
  4. Pass by ref. A work around?
    By diRisig in forum New To Java
    Replies: 0
    Last Post: 02-05-2008, 07:25 PM
  5. how would i get this to work...?
    By deeadeed in forum New To Java
    Replies: 6
    Last Post: 12-06-2007, 02:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •