PDA

View Full Version : "back buffer" problem with java



JAD
02-09-2008, 07:24 PM
Well I'm just starting to work with "back buffers" and my first attempt got an error while the script is running for some reason (the script compiles though). If I take this:



monsterBackg = blob.getGraphics();


out of the script, it works fine. But I'm trying to make a backbuffer so I kind of need that :p

Anyways, it's a problem with the getGraphics(); method:



exception: java.lang.UnsupportedOperationException: getGraphics() not valid for images created with createImage(producer).


The image blob was called properly above like so too:



blob = getImage(getDocumentBase(), "alien.gif");


Any ideas?

Thanks!

~JAD

yargo
03-15-2008, 10:11 PM
I'm not sure this is helping, but your exception is telling you that your images can only be declared in the form getImage(int Height, int Width) and you can't get it from something with graphics of its own already. Probably has something to do with how graphics can change, and it wants a static reference. Java is slightly weird in how you can and can't do things. You should be doing something like:

backbuffer = createImage( width, height );
backg = backbuffer.getGraphics();

for
Image backbuffer;
Graphics backg;

I hope you fix your problem!

JAD
03-16-2008, 12:13 AM
I'm not sure this is helping, but your exception is telling you that your images can only be declared in the form getImage(int Height, int Width) and you can't get it from something with graphics of its own already. Probably has something to do with how graphics can change, and it wants a static reference. Java is slightly weird in how you can and can't do things. You should be doing something like:

backbuffer = createImage( width, height );
backg = backbuffer.getGraphics();

for
Image backbuffer;
Graphics backg;

I hope you fix your problem!

I'm on laptop right now, so I don't have the source of it and can't change what you said right now but that sounds like it would fix my problem! Thanks a lot and I'll tell you if I have any errors/trouble with that if you are still able to help.

Thanks again (a lot)!

~JAD