Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wait and then change the picture

 
Jude Fawly
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,

consider i have an image on the canvas. i want the user when he clicks 2 on the keypad for example, i want the canvas to wait for about one second and then change the the image. I tried using Thread.sleep(1000) and then changing the picture reference and then calling repaint() method. But here i get a problem, the canvas always changes the picture and gets repainted and then gets idle for one second. In java stand edition, i use to use timers and calling it everytime "start and stop", but in J2ME i read that the timer won't work properly when called sequentially.

can somebody help me?
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

A hack would be to introduce a state value. In the block, that gets
excecuted when the user presses "2" you'll sleep for 1000 ms, then
change the state.



Do report back if the above doesn't work, or is a bad approach

/Svend Rost
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic