Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help w/ game involving threads and drawImage

 
Mike Frya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about the double post :roll:
So I am trying to write an applet that will be interactive- a picture will momentarily flash on the screen at a random spot for some short amt of time and then disappear only to appear in a dif spot. The user has to click on the picture to win.
I know that I should use 2 threads (maybe more?)but when I put the drawImage method in the 2nd thread (class ShowImage extends Thread) the method does not want to display the image. Any help would be appreciated!
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,
Welcome to JavaRanch. You can delete the second post yourself by selecting the edit icon at the top. It's the one that looks like a pencil and paper. Don't delete this one though.
For your problem. Are you using swing or AWT?
 
Mike Frya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip! I am on a laptop
so I tend to press keys by accident as I type and
unintended things happen...
I am using AWT
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I deleted the double post before I read Mikes directions to Mike.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Frya:
Thanks for the tip! I am on a laptop
so I tend to press keys by accident as I type and
unintended things happen...
I am using AWT

Instead of playing twenty questions with you, it might be best for you to post some code and let us take a look at it. Use the CODE button and paste (or type ) your code between the tags. AWT isn't as picky as swing is about displaying graphics outside the main event thread but it is usually wise to handle all of it in one place if you can.
 
Mike Frya
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic