This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

j2me repaint() quetion  RSS feed

 
ying lam
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a j2me repaint() quetion. I apprecaite if you can help me with that.

In my code, I call
repaint(x1, y1, w1, h1);

...

repaint(x2, y2, w2, h2);

...
repaint(x3, y3, w3, h3);

...
repaint(x4, y4, w4, h4); // note: x1 , x2, x3, x4 are all different values.

even though repaint() is call a-sync, I should still see paint() get called 4 times, right?

From my debugging, I see the no of paint() is less than the no of called i made to repaint().

Do you have any idea why is that?

Thank you.
 
Eduardo Marques
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, paint() is not necessarily called the number of times you call repaint(). Multiple repaint() requests may be merged into just one call to paint().

To ensure synchronized painting you can either use:
1) Canvas.serviceRepaints()

2) use GameCanvas which does everything Canvas does and provides the flushGraphics() call
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!