Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

repaint() calls paint() but i dont see paint() being called

 
Udit Manektala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I made this applet where it plays a MIDI sequence and upon encountering MetaMessages (Cue Notes) it changes some display parameters for a small red ball and calls repaint()

Well I can see that repaint() does get called everytime its supposed to. But in turn, paint() gets called only once midway through the program whereas i need the ball's position to get updated on the screen everytime repaint() is called.

I guess that repaint() just calls a thread which in turn calls paint() and paint requests might be collated, but how can i ensure that everytime I call repaint(), paint() will be called. In short, I need screen refreshes synchronized with the Midi Notes. How do I get that ?
 
Udit Manektala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I figured it out. I needed to spawn another thread that would call repaint(). this ensures that the paint() gets called everytime we call repaint();

More details here:
http://www.javaworld.com/javaworld/jw-03-1996/jw-03-animation.html?page=1
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic