File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "j2me repaint() quetion" Watch "j2me repaint() quetion" New topic
Author

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 J2MECertificate.com - See what all the buzz is about ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: j2me repaint() quetion