Solved

Graphics in a Class

Posted on 2004-09-28
4
281 Views
Last Modified: 2010-03-31
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.
0
Comment
Question by:samwaters
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12175868
can you post the complete error message
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 12175871
does the class making the call implement ImageObserver?

try:

grObject.drawImage(BObject, 10, 10, null);
0
 

Author Comment

by:samwaters
ID: 12175922
It said
cannot resolve symbol - method drawImage (java.awt.Image,int,int,ImageClass1)
0
 

Author Comment

by:samwaters
ID: 12175926
yes apparerntly putting null as ImageObserver keeps it happy - thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question