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.

Re: Java animation code

public Star() {

That looks like the syntax for a class's constructor. Is it in a class named: Star?

For the other errors, make sure the statements are inside of a method.

The code is not properly formatted making it hard to read and understand what it does.
Nested statements should be indented 3-4 spaces to show the nesting logic. All statements should NOT start in the first column.

Re: Java animation code

Originally Posted by Norm

That looks like the syntax for a class's constructor. Is it in a class named: Star?

For the other errors, make sure the statements are inside of a method.

The code is not properly formatted making it hard to read and understand what it does.
Nested statements should be indented 3-4 spaces to show the nesting logic. All statements should NOT start in the first column.

Please Edit the code and fix the formatting.

Hey! I redid the code as you asked, and now I only get one error. Could you help me figure out how to fix this error? Below is the code.

Re: Java animation code

Where should I define the setBackground and repaint methods?

You should not use those names for your methods. Sometimes when you want to override an extended class's methods then you must use the same name for your method.
When you call methods that are not in a class, then you need a reference to an instance of a class that has those methods. The class Board does not extend a class with those methods.

If you want to see what Java SE classes have those methods, go to the API doc site,
click on the Index link in the blue strip at the top right,
On the index page click on the first letter of the method and the find the method in the list of methods.
The classes the method is in will be shown next to the method's name.

Re: Java animation code

Ok. I know i'm not supposed to really explicitly ask, but do you think you could make my code work? I know you're one of the best on the site and could do it in an instance(no pun intended ). Because I have been trying all day and am getting really frustrated is the only reason i'm asking thank you norm

Re: Java animation code

What does the code in the Board class want to happen when it calls the methods in question?
Where are those methods defined? How can the code in the Board class get access to the class object that contains those methods?

Hint: the Board class is only a listener, it does NOT have any GUI stuff like a background.