I am a newbie to Java, if you could please help me with this problem. I am trying to run some graphics programs. I have downloaded acm.jar, and included its path in my eclipse reader. The errors I get in almost all my graphics programs are:
java.lang.Error: Unresolved compilation problems:
The import acm cannot be resolved
The import acm cannot be resolved
GraphicsProgram cannot be resolved to a type
The method getHeight() is undefined for the type BouncingBall
GRect cannot be resolved to a type
GRect cannot be resolved to a type
at BouncingBall.<init>(BouncingBall.java:3)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The program goes like:
import acm.program.*;
import acm.graphics.*;
import java.awt.*;
import acm.program.GraphicsProgram;
public class BouncingBall extends GraphicsProgram {
/** Runs the program */
public void run() {
double sqSize = (double) getHeight() / NROWS;
for (int i = 0; i < NROWS; i++) {
for (int j = 0; j < NCOLUMNS; j++) {
double x = j * sqSize;
double y = i * sqSize;
GRect sq = new GRect(x, y, sqSize, sqSize);
sq.setFilled((i + j) % 2 != 0);
add(sq);
}
}
}
/* Private constants */
private static final int NROWS = 8; /* Number of rows */
private static final int NCOLUMNS = 8; /* Number of columns */
}
I dont understand the error. Perhaps defining GraphicsProgram would solve the problem? How do I define that, I think it is suppose to be predefined.
Thank you

New Topic/Question
Reply



MultiQuote




|