FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Image in applet

 


quasar
I have a very simple applet that just tries to show one image. It works locally, however when I upload the class file, html file, and image file, it doesn't work properly. The html file opens, and the applet runs, however it remains blank. If I write an applet that shows lines, that works, however I cannot show any images. The filenames and paths are correct, including case. If I make an html file that shows the image, without using java it works. The code is below


Code:

import java.awt.*;
import java.applet.*;


public class JavaBMP extends Applet {

    Image CharImage;

    public void init() {
   CharImage = getImage(getCodeBase(), "Character.gif");    }

    public void paint(Graphics g) {
      g.drawImage(CharImage, 10,10, this);
    }

}
 
HamsterMan
I don't think getimage works on a webserver, although i could be wrong.

This is the code I used in one of my applets.

url = new URL(getDocumentBase(), "Graphics/Photo.PNG");
original = ImageIO.read(url);
PhotoImage = createImage(new FilteredImageSource(original.getSource(), new RGBImageFilter() {

{
canFilterIndexColorModel = true;
}

public int filterRGB(int x, int y, int rgb) {
if (rgb == 0xFFFF00FF) {
return 0xFFFFFF;
} else {
return rgb;
}
}
}));
Peterssidan
I see nothing wrong wit your code. Is the Image fully loaded before the paint method is called? What happens if you drag a window over the Applet to make it repaint?
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.