aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java Forums - Image only shows after screen is reloaded (hidden and showed again) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Forums - Image only shows after screen is reloaded (hidden and showed again)" Watch "Java Forums - Image only shows after screen is reloaded (hidden and showed again)" New topic
Author

Java Forums - Image only shows after screen is reloaded (hidden and showed again)

Leticia Barbalho
Ranch Hand

Joined: Sep 02, 2005
Posts: 37
Hello everyone,

I have a class that calls a drawImage. The thing is that it was supposed to be shown when the JFrame is shown, but it isn't. It is only shown after I hide it and show it again (like after I minimize it and minimize it back.

Can anyone help me here? I need it loading without nothing being done by the user.

Here goes my class:

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
The general symptom you describe comes from not fully–loading the image before trying to draw it. If you are using the older "getImage" or "createImage" methods you should use a MediaTracker to load the image. The MediaTracker api has example code showing how to use it.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You're doing a couple things that make me nervous:
1. Calling Component's getGraphics method -- and in a constructor, too!
That method is best avoided since it makes no persistent changes
in the component. When you repaint, that rendering will not be redone.

2. Overriding JFrame's paint method. Think art: the job of a frame is
to hold a painting, not to *be* the painting.


BTW -- I think this thread belongs in the "Swing / other things" forum.
I don't see the "other APIs" manifesting themselves...
[ November 22, 2005: Message edited by: Jeff Albrechtsen ]

There is no emoticon for what I am feeling!
Leticia Barbalho
Ranch Hand

Joined: Sep 02, 2005
Posts: 37
Thank you Craig, it worked perfectly.

Jeff... relax man. If you keep getting nervous like this because of other people's code you'll get old pretty soon. Anyway, thank you very much.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Okay, I've calmed down and I'm better, now. Read a few Hi and Lois strips.
But I have to admit, some code makes my head [er ... hair] stand on end!
[ November 23, 2005: Message edited by: Jeff Albrechtsen ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Forums - Image only shows after screen is reloaded (hidden and showed again)
 
Similar Threads
set the background of a JPanel with an image
using JFrame with KeyListener Interface and using paint method
ConvolvedOp with / without alpha premultiplication
Output image file and displaying it on screen
Background image in JPanel