How to display images outside an applet?
Posted on 2003-02-23
Hello, I'm making a little JAVA-program that should be able to show images. Displaying images in applets have never been a problem. But this program isn't an applet.
The problem is in my paint(Graphics g) method when I try to use g.drawImage(Image,int,int,ImageObserver). Because I cannot use 'this' as an ImageObserver that I do when showing an image in an applet. I have tried let the class implement ImageObserver and then use 'this' but it didn't work either.
My program now excists of 2 classes:
GUI (extends JFrame)
GraphicArea (extends Canvas)
And it's in the GraphicArea class that I have the paint method. And I create a GraphicArea object in the GUI class (I want to have a small graphic-field in the frame).
So, how do I use images in non-applet java programs? Or what can I use as an ImageObserver?