File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Images sometimes don't display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Images sometimes don Watch "Images sometimes don New topic

Images sometimes don't display

Matt Hansen
Ranch Hand

Joined: Jul 31, 2001
Posts: 34
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?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

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...


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Matt Hansen
Ranch Hand

Joined: Jul 31, 2001
Posts: 34
Thanks, that was the problem! I added that and now it displays every time.
I agree. Here's the link:
subject: Images sometimes don't display
It's not a secret anymore!