Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can't see image

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic