Image help

Ive made a little applet that puts a image on the screen. But nothing happens. Ive used the following code

class Dosomething extends java.applet.Applet
{
Image img = getImage(getDocumentBase(),"anyimage.jpg");

public void paint(Graphics screen){
screen.drawImage(img);
}
}

What is the problem???
GS

Comments

  • : Ive made a little applet that puts a image on the screen. But nothing happens. Ive used the following code
    :
    : class Dosomething extends java.applet.Applet
    : {
    : Image img = getImage(getDocumentBase(),"anyimage.jpg");
    :
    : public void paint(Graphics screen){
    : screen.drawImage(img);
    : }
    : }
    :
    : What is the problem???
    : GS

    Well there could be two things palying here first of all the drawImage
    method needs more parameters, it woulden`t even compile,one of the
    drawImage method signature is (Image img, int x, int y, ImageObserver
    observer). What you have to know is which image to draw and the exact
    location on the screen where you want draw (X,Y), the last parameter
    you don`t have to know you can simply put this, that because Applets
    implement the ImageObserver interface. The other thing could be that you
    have provided an invalid path. The drawImage method does not report
    errors, so if the path is missing the image won`t be desplayed.

    Hope that helps.



    -------==[QTZ]==------
    -==[QueezyTheGreat]==-

  • Thanks a lot!!! :))
    Ill try this as soon as I can. If I have more problems Ill report it.
    Thanks again!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories