jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Can't see image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic

Can't see image

Mike Clare

Joined: Jul 28, 2003
Posts: 1
This is my applet:
import java.awt.*;
import java.applet.Applet;

public class PictureMe extends Applet {
private Image image;
public void init() {
image = getImage(getDocumentBase(), "thermometer");
public void paint (Graphics g) {
g.drawImage(image, 20, 20, 242, 351, this);
The image is in the folder with the .class file and the html file
yet all I get is a blank field.
I have tried putting the suffex .jpg too.
What am I doing wrong.
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059

If the name of your image file is thermometer.gif, then you should use
image = getImage(getDocumentBase(), "thermometer.gif");

If the name of your image file is thermometer.jpg, then you should use
image = getImage(getDocumentBase(), "thermometer.jpg");

Otherwise, it worked for me.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link: http://aspose.com/file-tools
subject: Can't see image
It's not a secret anymore!