This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Images not shown in Applet

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steffen Schmitt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Water proof donuts! Eat them while reading this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic