Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Graphics in a Class

Posted on 2004-09-28
4
Medium Priority
?
315 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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 beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

722 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