Graphics in a Class

Hi,
I'm writing a class that displays an image and can be called from an Applet or something.
Anyway, I have a function setGraphics(Graphics g) which sets a global graphics variable to the parameter passed to it, so it can use the same drawing area as the Applet.
It then sets the image using this code:
BObject=Toolkit.getDefaultToolkit().getImage("somefile.jpg");
and then uses the graphics object to draw it:
grObject.drawImage(BObject, 10, 10, this);
But I get a Cannot Resolve Symbol error and I'm not sure why - the documentation says that drawImage is part of the Graphics class.
Am I mising an import or something? I have the following imports:
import java.awt.*;
import java.applet.*;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.*;

Any help would be appreciated.
samwatersAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
objectsConnect With a Mentor Commented:
does the class making the call implement ImageObserver?

try:

grObject.drawImage(BObject, 10, 10, null);
0
 
objectsCommented:
can you post the complete error message
0
 
samwatersAuthor Commented:
It said
cannot resolve symbol - method drawImage (java.awt.Image,int,int,ImageClass1)
0
 
samwatersAuthor Commented:
yes apparerntly putting null as ImageObserver keeps it happy - thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.