• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Timer update BufferedImage

 
C. Eche
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been trying to update a BufferedImage that is inserted to a GUI by using the Swing Timer. Initially I created the ImageIcon using the BufferedImage I get through a controller instance and then added it to JLabel (field). The current image was then shown on the GUI. Here a code snippet from the initial code inside the GUI class.



I’m trying now to get a BufferedImage every x seconds . For this purpose I used the Swing Timer class but unfortunately I haven’t been able to suceed. I created the following class with an ActionListener, so that every 3 seconds a new image is retrieved with the method getCameraImage.

Here the UpdateImage with the ActionListener class:




After the BufferedImage has been set as an ImageIcon I retrieve it with the getLabel method. And then add this component to the GUI.



The String "image update" shows up as desired every 3 seconds on the console. But the image won’t be diplayed on the GUI.

I'd really appreciate if someone could help me out on that by giving me some sort of hint or pointing out what I'm doing wrong.

Thank you.
 
Rob Camick
Ranch Hand
Posts: 2701
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quit cross posting: http://stackoverflow.com/questions/30143955/using-swing-timer-to-update-bufferedimage-on-gui/30144038#30144038

You got your answer in this posting before you even posted your question here.
 
C. Eche
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's true. thank you for that.
I just wanted to exhaust every possibility.
Nothing wrong with that.
 
Rob Camick
Ranch Hand
Posts: 2701
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing wrong with that.


Yes, there is. The problem with cross posting is people never bother to reply to all the posting stating the question has been answered or reposting the answer on the other postings so that all people know what the solution is.

It is annoying to spend time answering a question only to find out the same answer has already been given.

We don't have unlimited time to answer questions, so out time is better spend answering questions that don't have an answer.

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