Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Draw Image from inside separate class

 
Pedro Cerrano
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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)
{
myClass.drawMe(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.

-Pedro
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic