Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying java.awt.Image in a panel  RSS feed

 
Dave Sammut
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am having trouble with displaying an Image object on my panel within an applet.
I manage to display the image only after I scroll between windows i.e. alt+tab away from my applet window and then alt-tab back. I then see the image displayed in the applet's panel, however when I move(or even click) my mouse the image disappears again and I have to alt-tab back and forth to see the image displayed again.
any suggestions ?
thanks,
Dave
 
Dave Sammut
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,
The problem seemed to be a cause of the JRE not refreshing my panel often enough. I extended the Panel object, created a setter method for my image and added my image to g.drawImage(myImage.... to the paint method of the extended Panel class.
I hope this helps someone out there.
Thanks,
dave
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the setter method are you calling repaint()? This would repaint your panel with the new image when it gets set...
 
Dave Sammut
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I am not calling repaint()in my setter method however, it still paints the most recent image in good time. I'll add repaint() to the setter to further imporve things.
thanks,
dave
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!