i am a student completing my final assignment and i am stumped at the following error message. i have searched the internet including the sun java website but i don't know what could be causing this error in this shortened version of the applet. below is the error code that returns. i have shortened the code to try to isolate the issue, including changing the value of the keysArray from 5 to 6 to 10 just to be safe but i am at a loss what this error is trying to tell me. any input would be most appreciated. BTW i am not asking you to finish my homework just clarify what is happening.
thanks in advance
basic: Exception: java.lang.ArrayIndexOutOfBoundsException: 5
* Assgignment 3: MoveIt.java/html
* Programmer: Rafe McDonald
* Date: Dec 4, 2009
* Filename: MoveIt.java
* Version: 1.0
* Purpose: This is an applet that paints a graphic within a frame and prompts the user to move the image around the frame using clickable
* buttons. The applet will use the layout manager and loop structures to test for the actionListener of the appropriate buttons.
cup = getImage(getDocumentBase(), "cup.gif");
Canvas myCanvas = new Canvas();
// construct and label the buttons for input
keypad = new Panel();
keysArray = new Button;
keysArray = new Button("north");
keysArray = new Button("south");
keysArray = new Button("east");
keysArray = new Button("wesh");
keysArray = new Button("centre");
// add components to keypadPanel
// add panel and canvas to the layout
macpro 2x2.8 quad intel, 10.5.8, ide blueJ
Joined: Dec 05, 2009
ok so i found the error in my full code - i had a typo that overlooked in assigning the keypad.add keyArray . Border .... statement - i had a 5 in the last line but now i am confused why the simpler version is still casting the same error when it does not contain the same typo.
i wonder if any of this could have been due to system issues. during the later stages of the day during work on this code, firefox started misbehaving. specifically highlighting text and scrolling were not functioning correctly. shortly after i made the first post i did some system maintanence and got things working.
any way thanks for confirming that the shorter version of the code works as expected. a relief to know.