I added about 20 images to a form and each image is representing a question. When a particular image is selected, I remove the components in the form's content pane and display that question. When the question is answered, I remove the components of the form's content pane again, and add the other images for the user to select another question. All these while, the person is being timed.
My problem is that I call form.revalidate() on the following occasions:
1. timer event,
2. as the user selects a question,
3. as the user answers a question and
4. as the images are displayed again.
This is the stack trace of the error, I got from logcat.(The application crashes on my Android device)
W/dalvikvm(22064): threadid=17: thread exiting with uncaught exception (group=0x40af39f0)
E/AndroidRuntime(22064): FATAL EXCEPTION: Timer-4
E/AndroidRuntime(22064): java.lang.IndexOutOfBoundsException: Invalid index 23, size is 23
E/AndroidRuntime(22064): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
E/AndroidRuntime(22064): at java.util.ArrayList.get(ArrayList.java:304)
E/AndroidRuntime(22064): at com.codename1.ui.Container.getComponentAt(Container.java:991)
E/AndroidRuntime(22064): at com.codename1.ui.Container.doLayout(Container.java:962)
E/AndroidRuntime(22064): at com.codename1.ui.Container.layoutContainer(Container.java:951)
E/AndroidRuntime(22064): at com.codename1.ui.Container.doLayout(Container.java:964)
E/AndroidRuntime(22064): at com.codename1.ui.Container.layoutContainer(Container.java:951)
E/AndroidRuntime(22064): at com.codename1.ui.Container.doLayout(Container.java:964)
E/AndroidRuntime(22064): at com.codename1.ui.Container.layoutContainer(Container.java:951)
E/AndroidRuntime(22064): at com.codename1.ui.Container.animateLayout(Container.java:2106)
E/AndroidRuntime(22064): at com.codename1.ui.Container.animateLayoutAndWait(Container.java:1788)
E/AndroidRuntime(22064): at userclasses.StateMachine$8.run(StateMachine.java:435)
E/AndroidRuntime(22064): at java.util.Timer$TimerImpl.run(Timer.java:284)
stateMachine.java:435 has
f.animateLayoutAndWait(800);
I have attached an extract from my source code, indicating the various places that i was re validating the form.