wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic
Author

Can't see image

Mike Clare
Greenhorn

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.
Mike
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10

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.


JavaBeginnersFaq
"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
 
Similar Threads
Unable to set label icon
LOADING .TIFF IMAGES INTO AN APPLET
Can't run my applet on a html page
Images in Java
about image. see this simple code please.