CSE142—Computer Programming I

Programming Assignment #3

Debugging Hints

Java Version

You can get a significant pixel difference if you are using an older version of Java.  You can find out which version is running by going into the interactions pane in jGRASP and typing in the following:

System.getProperty("java.version")

You should see a response like the following:

1.8.0_60

If it begins with “1.6”, then you are using Java 6 and need to update to a newer version.  We recommend using Java 8, but Java 7 would be acceptable.  To change which version of Java jGRASP is using, go to Settings, jGRASP Startup Settings, and look for “Java executable for running jGRASP.”  Pick something that begins with “1.7” or “1.8.”  If you don’t see something that begins with “1.7” or “1.8”, then you need to install a newer JDK first by following the instructions on the “Working at Home” tab on the class web page.

Drawing Counts

It is possible to get a large pixel difference if you draw the same line or box multiple times.  The DrawingPanel class has an option to help you explore this.  Set up your Graphics object this way:

Graphics g = p.getDebuggingGraphics();

When you do so, you can include the following line of code at the end of main:

System.out.println(p.getCounts());

This is the output produced for the sample solution:

{drawLine=234, fillRect=234}

You do not have to match these counts if you are within 500 pixels of difference.