how do I repaint an applet while moving a sprite?

Posted by Nagrom_17 on Stack Overflow See other posts from Stack Overflow or by Nagrom_17
Published on 2009-05-26T19:38:12Z Indexed on 2010/06/02 4:03 UTC
Read the original article Hit count: 109

Filed under:
|
|

I have a little java applet where I create 2 threads, one thread repaints and the other moves an image from a point to where the user clicks. The problem is that when I call the move function it loops until the image is where the user clicks but it wont repaint until I break out of the loop even though the thread doing the moving and the thread doing the painting are separate.

shortened version of key points:

  • my program is an applet using the paint() method

  • I have 2 threads one moves an image and the other paints that image

  • when I am moving the image it is in a while loop

  • the painting thread is still calling repaint() but that is as far as the call goes, it never repaints

thank you for your time.

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading