Implementing a blocking modal dialoig in J2ME, MIDP1.0/CLDC1.0
posted 8 years ago
Hi guys.. I'm posting because I dont know much about the way java ui runs with respect to threading.. Infact, I dont know how many threads a J2ME app would run to write hello world on the screen, or how I would pause them but maintain responsiveness.
//some code.. oh we need to ask the user a question Question q = new Question("Really quit?", "yes", "no"); if(q.ask() == "yes") //quit..
And I want to block the execution of the current thread just like we are used to from e.g. windows message boxes.. I know there isnt any code in there to revert to the previous screen yet, i dont know if there is a way to do that easily? Does the Display class keep a history so I can just say hide() or showThePreviousScreenAgain().. Can an Alert block the thread? Can it have variable answers?
In the debug window of WTK, i can see (via debug println) that the code shows the question, gets to the wait() and bombs with an IllegalMonitorState ; i presume I'm not locking on the same thread that created the lock. I've tried locking on the display, on this (the ui hangs), on the main midlet class.. and none of them work as expected. Can anyone offer any pointers? There is an accessory discussion going on at http://www.codeguru.com/forum/showthread.php?p=1691066