Posted on 2001-07-16
Im trying to write a component that peoduces a nice graphics effect, and I want it to be compatable with IE 4...
The problem is making a buffered image to use, and getting it's handle.
In Java 2, I have been using:
private BufferedImage buffImage=new BufferedImage(360,370,BufferedImage.TYPE_INT_RGB);
which has been fine, but doesn't work in IE 4, so I can't use it.
So I wrote a small method thusly:
private void createBufferedImage()
It's great but it stops every single time with a null pointer exception when the JVM gets to the getGraphics() method, DAMN!
I was reading a book, and it said put it in your paint(Graphics g) method, like so:
public void paint(Graphics g)
buffer.blah blah blah............
This version works! But two things I dont understand...
Why does the very same createImage folowed by getGraphics commands work in the paint method, but not in my createBufferedImage method, which always throws that exception, and why do I have to create my buffer in the paint method, EVERY time checking to see if it's been produced already? I just want to create it, and refere to it FROM paint, not mess around checking if it exists in there!
If you really want, I can supply the full code...