Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: Cannot figure out error

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cannot figure out error

    leftInnerEar.setFilled(true);
    leftInnerEar.SetColor(Color red)

    When I try to compile I get the error message " ')' expected" but have no idea why this is happening. Thank you for your help

    --- Update ---

    There is an ";" at the end of the second line of code


  2. #2
    Member
    Join Date
    May 2013
    Posts
    96
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: Cannot figure out error

    Error messages like that usually mean you left something open, like a ( [ { or " without an accompanying ) ] } or ". But in this case I think it looks like you either forgot the semicolon at the end of your 2nd statement or you made a syntax error in setting the color. It should be Color.red (or RED). You're accessing a static integer constant in the Color class.

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: Cannot figure out error

    String str = "hello";
    System.out.println(String str);
    What is wrong with that code?
    Improving the world one idiot at a time!

  4. #4
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot figure out error

    leftInnerEar.setFilled(true);
    leftInnerEar.SetColor(Color.RED);

    With this as my code I get "cannot find symbol - variable Color"

  5. #5
    Member
    Join Date
    May 2013
    Posts
    96
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: Cannot figure out error

    Did you import java.awt.Color?

  6. #6
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot figure out error

    Yes

  7. #7
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: Cannot figure out error

    Post your code. If it is too long then create a SSCCE.
    Improving the world one idiot at a time!

  8. #8
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot figure out error

    import acm.graphics.*;
    import acm.program.*;
    import java.awt.Color.*;

    // -------------------------------------------------------------------------
    */
    public class Cartoon extends GraphicsProgram
    {
    //~ Instance/static variables .............................................

    //~ Constructor .................................................. .........

    // ----------------------------------------------------------
    /**
    * Creates a new Cartoon object.
    */
    public Cartoon()
    {
    GOval Face = new GOval(300, 150, 100, 200);
    add(Face);

    GOval leftEar = new GOval(280, 125, 50, 50);
    add(leftEar);
    GOval leftInnerEar = new GOval(295, 140, 20, 20);
    add(leftInnerEar);
    leftInnerEar.setFilled(true);
    leftInnerEar.SetColor(Color.red);

  9. #9
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: Cannot figure out error

    import java.awt.Color.*;
    This does not import the Color class. It imports all classes in the awt.color package.
    Improving the world one idiot at a time!

  10. #10
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot figure out error

    I'm not sure what that means, sorry I'm really new at this

  11. #11
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: Cannot figure out error

    Just remove the asterisk to import only the Color class.
    Improving the world one idiot at a time!

  12. #12
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot figure out error

    I get "<identifier> expected"

  13. #13
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: Cannot figure out error

    I cannot see your latest code. Crystal ball says:
    import java.awt.Color.;
    Surely a bright person can work out the problem.
    Improving the world one idiot at a time!

  14. #14
    Junior Member
    Join Date
    Sep 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Cannot figure out error

    This is what I have.

    import acm.graphics.*;
    import acm.program.*;
    import java.awt.Color;

    // -------------------------------------------------------------------------
    */
    public class Cartoon extends GraphicsProgram
    {
    //~ Instance/static variables .............................................

    //~ Constructor .................................................. .........

    // ----------------------------------------------------------
    /**
    * Creates a new Cartoon object.
    */
    public Cartoon()
    {
    GOval Face = new GOval(300, 150, 100, 200);
    add(Face);

    GOval leftEar = new GOval(280, 125, 50, 50);
    add(leftEar);
    GOval leftInnerEar = new GOval(295, 140, 20, 20);
    add(leftInnerEar);
    leftInnerEar.setFilled(true);
    leftInnerEar.SetColor(red);

    Now I get an error "cannot find symbol - method SetColor(java.awt.Color); maybe you meant : getColor() or setColor(Color)"

    --- Update ---

    I got it, I am an idiot. I had a uppercase "S" in the second line. Thank you for your help

Similar Threads

  1. Can't figure out my error
    By bigtrouble187 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 29th, 2012, 01:15 PM
  2. Error I cannot figure out for the life of me
    By KuruptingYou in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 3rd, 2011, 07:44 AM
  3. I can't figure out why i keep getting this error
    By chrissy2860 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 17th, 2011, 03:06 PM
  4. just one more error that i cannot figure out please help me.
    By knoxy5467 in forum What's Wrong With My Code?
    Replies: 31
    Last Post: June 14th, 2011, 09:04 AM
  5. Simple error can't figure out.
    By n00bprogrammer in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 30th, 2010, 12:19 PM