Link to home
Start Free TrialLog in
Avatar of Peppe
Peppe

asked on

Strange problem with getimage()...

Hi, my name is Peppe from Rome

I have a terrible and strange problem : all my program that use the instruction "getimage" does not function because the function return "null" value. All programs some days ago played perfectly.

This is an example :

import java.applet.*;
import java.awt.*;    
import java.net.*;    
import java.io.*;    
import java.lang.System;      

public class me extends Applet {
Image miaimage1 = null;

public void init() {
miaimage1 = getImage(getDocumentBase(), "quadri.jpg");}

public void paint(Graphics g) {
if(miaimage1 != null)
    g.drawImage(miaimage1, 50,10, this);
    else g.drawString("Error image", 30,50);
  }
}

----------------
Result is always "Error Image" (In Netscape 4.0 and Microsoft Explorer 3.0)
ASKER CERTIFIED SOLUTION
Avatar of jpk041897
jpk041897

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mgk
mgk

Hi JPK and Peppe,

Remember that the call to java.applet.Applet.getDocumentBase() returns a URL so there shouldn't be the need to seperately instantiate another URL for loading the image. You've changed which method is used but I still can't see why the original code won't work. The next obvious thing is that "quadri.jpg" is actually there and the filename is spelt right.

The fact that everything was perfect a few days ago makes me think you should flush your browser cache and try again - particularly Netscape 4 because it just wierd stuff to applets.

Cheers,

Mark King (mgk)


Avatar of Peppe

ASKER

Yes, Java code is certainly good, reasons of error must be on system.  Thank you