Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why delays in drawing images  RSS feed

 
Ken Duncan
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[size=13]
I have a question about the execution of code to draw images relative to code that comes after that. I don't normally do this sort of thing. My most recent Java programming has been servlets and JSPs, and I'm asking this (honestly!) for someone else, whom I've gotten interested in Java. I have a hunch, but here's the problematic code:

The person who wrote this said,

"When the attached code is run, the calls to TimeKeeper.pause(500), which in turn call Thread.sleep(500), are all executed in row, and then the results of drawing the image 10 times is displayed. (I know because some of the previous image pastes left some visual data behind.)"

I recall from reading about drawing graphics (a long time ago) that drawImage() could take time, but I don't know why the thread does not indeed sleep between calls to drawImage(). Any suggestions?
[/size]
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Concurrency in Swing. There is only one thread for handling any event in Swing, including drawing, and if you're making that thread sleep then the GUI will do nothing - not even (re)draw itself.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!