This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Applets and the fly likes Images not shown in Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Images not shown in Applet" Watch "Images not shown in Applet" New topic
Author

Images not shown in Applet

Steffen Schmitt
Greenhorn

Joined: May 08, 2008
Posts: 14
Hi all!

I'm trying to write a simple site-navigation Applet using Java2D for painting the Applet.

What I've got so far worked (that is, images were displayed the way I expected) but now (and I can't figure out why) the Applet and the gradient paint in the background are shown, whereas the images are not. Debugging the Applet doesn't help, as the images are initialized using Applet parameters defined in the enclosing HTML page.

This is what I have written:



The Applet's parameters are defined correctly in the enclosing HTML page (for better readability, I assigned a value of "null" in the param tag when no image fhile exists. This isn't used in the Applet):



I'd be grateful for any suggestion, as I really can't figure out what went wrong.

Thanks in advance -

Steffen


The man who sets out to carry a cat by its tail learns something that will always be useful and which never will grow dim or doubtful.
-- Mark Twain
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35247
    
    7
Why are you using the "buffer" object for drawing? If you pass the "g2" object from the paint method into the prepareImage method, then you can use that for drawing directly.


Android appsImageJ pluginsJava web charts
Steffen Schmitt
Greenhorn

Joined: May 08, 2008
Posts: 14
Ulf Dittmer wrote:Why are you using the "buffer" object for drawing? If you pass the "g2" object from the paint method into the prepareImage method, then you can use that for drawing directly.


I thought I'd need the reference to a BufferedImage for double-buffered painting of the Applet. But why are th images not displayed? They were at first and then all of a sudden (do those things ever happen otherwise?) they weren't any more. That was about at the time when I was trying to calculate the images' bounding boxes. So, as far as I know, nothing of any structural importance had changed, but the images were gone ... strange!

I'll give it a try with passing in the g2 from the paint method, though. Thanks a lot for your recommendations!

Cheers -

Steffen
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Images not shown in Applet
 
Similar Threads
Image Question
Rotating a JWindow with multiple JPanels
Whats wrong with this?
Paint
LOADING .TIFF IMAGES INTO AN APPLET