Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Java Micro Edition and the fly likes j2me repaint() quetion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "j2me repaint() quetion" Watch "j2me repaint() quetion" New topic

j2me repaint() quetion

ying lam
Ranch Hand

Joined: May 17, 2004
Posts: 85
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

Joined: Feb 19, 2005
Posts: 231
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

Eduardo Marques
Get ready for your SCMAD certification at - See what all the buzz is about ...
Don't get me started about those stupid light bulbs.
subject: j2me repaint() quetion
Similar Threads
Problem with java layout and panels and containers
Corba specification or vendor implementation behavior?
This is Homework Just need a hint:?????
Recursion SnowFlake ?