File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes Draw Image from inside separate class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Draw Image from inside separate class" Watch "Draw Image from inside separate class" New topic

Draw Image from inside separate class

Pedro Cerrano

Joined: Nov 07, 2004
Posts: 1

I'm having a problem trying to draw an image that is stored inside a separate class. In the paint method, I am trying to do something like below.

public void paint(Graphics g)
-this calls a method for my class
Inside the drawMe method of the myClass class, it would go something like this.

public void drawMe(Grahpics g)
g.drawImage(createdImage, xPos, yPos, this);

The problem is that 'this' will refer back to the class, not the image object that I need for the ImageObserver. In other words, it gives me an error because 'this' does not meet the ImageObserver parameter because it is inside of a separate class. Is there something I can replace 'this' with so that I will be pointing to the right kind of object and be able to draw the image from inside the class's draw method?

Thanks for the help.

I agree. Here's the link:
subject: Draw Image from inside separate class
It's not a secret anymore!