So i have an image being drawn inside a void method in my main class, and every tutorial i have looked at has told me to just write ‘this’ in the last field of the drawImage() method.
Unfortunately, obviously since this is inside a void method, ‘this’ does not work.
How do I deal with this?
Is there a way to create a local ImageObserver variable?
I dont need to use it really.
Code snippets:
URL iurl = new URL("cyn.png");
Image bi = Toolkit.getDefaultToolkit().getImage(iurl);
graphics.drawImage(bi,d.width/2+10,110,128,128,iob);
i dont know what else i need to show
i imported the Image class and graphics class
If you don’t need to use the image observer, you can safely pass
nullas argument. (It’s basically only used when loading images asynchronously.)From The Java™ Tutorials: Drawing an Image: