This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
This is supposed to be simple coloring book program, but I can't find out why it is giving me errors.
This is the output
we're in main setting up gui getting images setting up ImageList Loop is 0 out of 0 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at CustomPaint.UniCode.getImageList(CustomPaint.java:84) at CustomPaint.UniCode.setUpGui(CustomPaint.java:40) at CustomPaint.CustomPaint.main(CustomPaint.java:16)
I am pretty sure the for loop in getImageList is throwing the error. The file dir declared at the beginning is real and the folder it is reffering to has two files, test.gif and test2.gif KcolorChooser is another class in a different file it compiles and runs fine. FloodFill is a flood filling algorithm that I tested and it also works fine. Any help would be appreciated.
will visit each element once. Note the "<" rather than "<=". The last element of the array is at index X-1.
Now, the error message suggests that element 0 is out of bounds -- i.e., that there are no files in the list. This is at odds with what you're telling me, so something's not right. One thing you might try: convert the filename to lower case (using String.toLowerCase()) before checking for .gif; although Windows filenames aren't case-sensitive, Java Strings are.