FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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?
Related topics
Image resizer
Random image for your gallery
Image transparency script
Replace the art and personal pictures with an image gallery?
Can some install Image Magick?
Image Processing in C++ by Shirish
Tutorial: Image Rollovers w/ Javascript
PHP Image Upload (MySQL/Folder)
online / offline image dilemma
How To Make A Mini-Image for safedisc 4
phbb skin
PHP image uploads with progress bar AND resizing? [Resolved]
Make a image out of a webpage?
Free high-quality image hosting + prize
Reply to topic    Frihost Forum Index -> Scripting -> Others

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