Results 1 to 2 of 2
  1. #1
    courteous is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Red face (Trying to) fill HSB (Hue|Saturation|Brightness) array

    I'm getting
    Java Code:
    ArrayIndexOutOfBoundsException: 0
    when trying to fill the array with Hue values (Saturation and Brightness remain 100%):
    PHP Code:
    private Color[] hsb = new Color[numberOfCircles]; //outside method
    float h=0; //in method
    float raise=(1.f/numberOfCircles);
    for (int i=0; i<stKrogcev; i++) {
        hsb[i]=Color.getHSBColor(h,1.0f,1.0f); //getHSBColor: "Creates a Color object based on the specified values for the HSB color model."
        h+=raise;
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Insufficient code. To get better help faster, post a SSCCE. Link: SSCCE : Java Glossary

    It appears that your array is initialized with 0 length i.e. numberOfCircles was zero when you declared it.

    Of course, you may have two different variables with the same name. Or some other bug, who really knows?

    db

Similar Threads

  1. How to Fill Arc in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-24-2008, 12:14 AM
  2. How to Fill a Polygon in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:10 AM
  3. Replies: 0
    Last Post: 04-23-2008, 09:15 PM
  4. Array Fill Test
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:45 PM
  5. Replies: 0
    Last Post: 04-14-2008, 09:43 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
  •