For Programmers: Free Programming Magazines  


Home > Archive > Java Help > December 2004 > getGraphics() not valid









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author getGraphics() not valid
vizlab

2004-12-21, 3:57 am

Hi:
On windows XP, I have a servlet in which ToolkitImage calls
getGraphics().
The error below always occurs:

java.lang.UnsupportedOperationException: getGraphics() not valid for
images created with createImage(producer)
sun.awt.image.ToolkitImage.getGraphics(Unknown Source)

Basically, I use BufferedImage to generate a image and then save it.
But when I generate the image, for some reason,
ToolkitImage.getGraphics() is used. This triggered exceptions.

I have already set -Djava.awt.headless=true when starting tomcat.

When I run the servlet on linux, it works fine.
When I run the servlet in eclipse on Window XP, the error occurs.
Can anybody tell the reason?
Thanks a lot for your help.

Best

Lian
Boudewijn Dijkstra

2004-12-21, 8:57 am

"vizlab" <lianjian@caip.rutgers.edu> schreef in bericht
news:f406ff9.0412201907.2fb300a6@posting.google.com...
> Hi:
> On windows XP, I have a servlet in which ToolkitImage calls
> getGraphics().
> The error below always occurs:
>
> java.lang.UnsupportedOperationException: getGraphics() not valid for
> images created with createImage(producer)
> sun.awt.image.ToolkitImage.getGraphics(Unknown Source)
>
> Can anybody tell the reason?


Simple: because it is an unsupported operation. Make sure you call
getGraphics() on the BufferedImage, not on the ToolkitImage.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com