app is an Applet object passed in through the constructer in an earlier segment of code. When I run the applet it doesn't show the image. I've tried drawing rectangles before and after the image loading/displaying, and the rectangles show up but without the image. I tried loading the image in my applet class and the image loaded. What am I doing wrong?
06-09-2006, 04:31 AM
drawImage(currImage, 5, 5, null) ?
by the way: it could be, that loading the image is not finished, when you paint it.
for such cases you have to use the mediatracker, which will wait for the image to be loaded before it continues.
06-09-2006, 04:34 AM
and also: you paint the image on the buffered image and not on the applet.
you will have to paint your image on the applets graphics object, eg in the paint(Graphics g) method of the applet:
((Graphics2D)g).drawImage(currImage, 5, 5, null)
and not on a seperately created buffered image.
06-09-2006, 11:08 AM
Well I need to get a bunch of Images onto a BufferedImage later, but right now I'm just trying to get it to draw one to get it to work. I tried putting null instead of app and nothing works. I also used a MediaTracker to make it not add the image until it was loaded. None of those worked. Any other ideas?
Edit: nevermind, found that none of my images were loading for some reason.
06-09-2006, 11:46 AM
you have to paint your buffered image onto the graphics of the applet. as far as can see, you paint everything on the buffered image, but not the buffered image on the applet.
06-09-2006, 11:50 AM
I already had a method to paint the buffered image. It takes in a Graphics object and paints the buffered image to that graphics object. I just didn't include it because I felt it was unnecessary to. Also, I check how many images had loaded during each frame and it keeps saying 0 have loaded.
Edit: figured it out. I forgot to make the mediatracker check all the images every frame.