• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing a blocking modal dialoig in J2ME, MIDP1.0/CLDC1.0

 
Caius Jard
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

I read this thread: http://developer.sonyericsson.com/thread.jspa?&threadID=37983&start=0
which gave me a few pointers.

I then wrote this code, that doesnt work:


I want to be able to say:

//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

Cheers guys!
cjard
[ February 29, 2008: Message edited by: Caius Jard ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic