• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image capturing

 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey folks,
i grab an image saved in a file (.jpg) and show draw it on a JPanel in the JFrame. I use Tookit.getDeafaultToolkit().getImage("...") for it. Now, i make a loop which repaints the JPanel with the image once per 10 seconds. I thought that if I'd save another image with the same name
in the upcoming repainting the new image will be painted. But I was wrong. I replace the old image with the new one, or I even just delete the old image, but the reapinting continues to show the old image. Just for your info: I run
Tookit.getDeafaultToolkit().getImage("...") every new loop.I thought it grabs the image every time it runs, but it seems I was wrong.
The interesting fact is that if I put a flag and beginnig from one of the loops place a name of another image in the Toolkit.bla bla bla method everything works fine-I get another image.
Where is the trick?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make sure that the system knows that the new Image is really a new Image ( I assume that there is some kind of caching of Images behind the scenes... ), you'll have to get the bytes of the Image from an input stream and create the image from it's bytes...

Here's some code to help you out...



-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!