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 Murach's Java Servlets and JSP this week in the Servlets 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.

It is sorta covered in the JavaRanch Style Guide.
subject: Draw Image from inside separate class
Similar Threads
Java Forums - Image only shows after screen is reloaded (hidden and showed again)
ImageObserver interface
placing an image into a panel
Still not working..help please.
using a frame inside an applet