Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Image capturing

 
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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
 
Our first order of business must be this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic