I am developing an app in Java ME using Netbeans IDE, where I'm creating 3 Forms which contains
Command (OK and back) and
Image in the 1st
Command I can transfer the control to the 2nd form. This works
Form I have 2
Command OK and Back. On click of OK it should go to the 3rd
Form. On click of back it should return to the 1st
When I am in the 2nd
Form, I'm neither able to transfer to the 3rd nor to the 1st
I am getting the following exception.............
(stack trace incomplete)
An exception occurred during transition paint this might be valid in case of a resize in the middle of a transition
Please help me out.
Thanks in advance
Sanjay's answer is correct however if it doesn't solve the problem I would guess you have a recursion somewhere in your code leading to a stack overflow. Many J2ME VM's fail in triggering the stack overflow exception and instead throw an out of memory error.
Just use a debugger and walk over the code to see the recursion.
With the informations you provided, The possible issue is with the image in the first form, you need to keep track of the size of the image you are using. When an image is loaded, the data is decompressed to a pixel array. Pixels can need anything from 2 to 4 bytes each, depending on the device.Say an 800x600 image has 480,000 pixels, so will need at least 1Mb of heap (possible as much as 2Mb) to load it. This will explain why you are running out of memory. During a transition it may be LWUIT makes a local copy of the Image to "transform" (redraw) it(though I'm not sure) so its not a surprise if you need more memory while transition.
Here is a good read which might help you : Memory Leaks In LWUIT And Tracking Memory In Java ME
You can extend the memory of the emulator. You have to click on Properties of the project / Platform / Manage emulators / Tools & extensions / Open preferences / Storage In this window you will see heap size, write here 1000 f.e. and try it again.
When you swiching to 2nd or 3rd pass object of that class & display object(which is from mdilet) with next form constructor, and when you calling back button just write one line of code like
display.setCurrent(previous_form_object); & you know how to go next form when you clicking ok command. And one thing which is mentioned by Sanjay.