Solved

Graphics in a Class

Posted on 2004-09-28
4
253 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 87
What is JNDI datasource in spring 1 38
Python Assistance 7 36
Securing Jmx Console and web console 2 48
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now