File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Images sometimes don't display

 
Matt Hansen
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an ImagePanel which extends JPanel. I use this to display images by overriding the paint method. Usually the image appears but sometimes it doesn't appear until I manually force it to be redrawn by moving a window in front of it. Anyone have an idea how to fix this?
Thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be that you need to load the image with MediaTracker before trying to display it... but I don't know unless I see your code...

Here's a similiar class I made with the AWT Panel that works...



HTH,
-Nate
 
Matt Hansen
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that was the problem! I added that and now it displays every time.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic