Results 1 to 5 of 5
  1. #1
    tobymeister is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Need help with creating colors

    I am supposed to:

    Create a new scenario called test-pattern that uses a loop and an array to produce the image below on the standard Greenfoot scenario screen (a super method call with parameters 600, 600, and 1). Use the array to store the RGB values of the colors.

    This is what I have:

    [I]import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
    import java.awt.Color;

    /**
    * Write a description of class Chart here.
    *
    * @author (your name)
    * @version (a version number or a date)
    */
    public class Chart extends World
    {
    Color[] palette = { new Color(255,255,255), new Color(204,255,0), new Color(0,0,255), new Color(0,255,0), new Color(255,0,255), new Color(255,0,0), new Color(0,0,102), new Color(0,0,0), };
    /**
    * Constructor for objects of class Chart.
    *
    */
    public Chart()
    {
    // Create a new world with 600x600 cells with a cell size of 1x1 pixels.
    super(600, 600, 1);

    makeColor();
    }

    public void makeColor()
    {
    for(int i = 0; i < palette.length; i++)
    {
    addObject(new Color(palette), (i*75), 600);
    }
    }
    }


    I am getting the error:

    cannot find symbol - constructor Color(java.awt.Color) (referenced above in bold).

    I am taking a six week course in Java using Greenfoot. This, I am sure, is a very simple explanation and I am missing something very simple. Can someone please explain? Thank you.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,843
    Rep Power
    8

    Default Re: Need help with creating colors

    Your palette variable is an array of Color Objects, right? And you're passing it into Color's constructor. Where in the API do you see a Color constructor that takes an array of Colors as an argument?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    tobymeister is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Re: Need help with creating colors

    Thank you for your help. I got it!

  4. #4
    immortal is offline Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    Default Re: Need help with creating colors

    I have this same issue. any suggestions?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help with creating colors

    Quote Originally Posted by immortal View Post
    I have this same issue. any suggestions?
    This thread has already been answered. If you have the same problem, then use the same solution. If this doesn't help, then wouldn't it be wise to tell us more about your problem? But do so in a new thread rather than hijacking this one. Locking this old thread.

Similar Threads

  1. How do i add colors
    By ytrewqc in forum New To Java
    Replies: 1
    Last Post: 11-01-2011, 02:15 PM
  2. Convert 24 bit colors to 16 bit
    By i4ba1 in forum Advanced Java
    Replies: 2
    Last Post: 12-09-2010, 01:23 AM
  3. Rectangle and Colors
    By urbim in forum Java Applets
    Replies: 0
    Last Post: 07-11-2009, 03:03 PM
  4. Colors and shapes.
    By Torgero in forum New To Java
    Replies: 14
    Last Post: 10-13-2008, 05:25 PM
  5. change colors
    By calblue in forum New To Java
    Replies: 1
    Last Post: 12-02-2007, 11:52 PM

Posting Permissions

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